Skip to content

Instantly share code, notes, and snippets.

@glorat
glorat / ChatGPTClient.ts
Created June 7, 2024 06:50
ChatGPTClient - Typescript
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
/**
* Taken from https://github.com/glorat/node-chatgpt-api/blob/main/src/ChatGPTClient.js
* but with the following mods to make it browser friendly:
* - Replace cacheOptions with cache, to decouple from keyv, which doesn't work in browser
* - Remove undici, which doesn't work in browser
* - Remove proxying support
* - use uuid instead of crypto
@glorat
glorat / up.mjs
Created June 7, 2024 06:25
Upgrade a typescript project to langchain v0.2
import { updateEntrypointsFrom0_x_xTo0_2_x } from "@langchain/scripts/migrations";
const pathToMyProject = "./functions/src"; // This path is used in the following glob pattern: `${projectPath}/**/*.{ts,tsx,js,jsx}`.
updateEntrypointsFrom0_x_xTo0_2_x({
projectPath: pathToMyProject,
tsConfigPath: "tsconfig.json", // Path to the tsConfig file. This will be used to load all the project files into the script.
// testRun: true, // If true, the script will not save any changes, but will log the changes that would be made.
shouldLog: true,
});
@glorat
glorat / cloudbuild.yaml
Last active May 7, 2024 13:50
Import unstructured-api image to artifact registry for use with Google Cloud Run
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- 'pull'
- 'quay.io/unstructured-io/unstructured-api:latest'
- name: 'gcr.io/cloud-builders/docker'
args:
- 'tag'
- 'quay.io/unstructured-io/unstructured-api:latest'
- 'asia-southeast1-docker.pkg.dev/glorat-gptapps/sg-unstructured/unstructured-api:latest'
@glorat
glorat / gist:2179505f380b9984cb4f
Last active August 29, 2015 14:05
Brainwallet bitcoinsig with bitcoinjs-lib 1.0.3 - And a bug
/**
* Created by Kevin Tam on 08/08/2014.
*/
var Base58 = require('bs58');
var Crypto = require('crypto');
var BigInteger = require('bigi');
var assert = require('assert');
var Bitcoin = require('../../')