From e25eab97ebbca7d4955759354ef481dbd036be61 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Tue, 2 May 2023 01:44:08 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 22 ++++++++++------------ pnpm-lock.yaml | 7 +++++++ src/fluent-scratch.ts | 6 +++--- src/llm.ts | 8 ++++++++ 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index e58f32f..2701624 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,6 @@ "engines": { "node": ">=14" }, - "workspaces": [ - "packages/*" - ], "scripts": { "build": "run-s build:*", "build:tsup": "lerna run build --no-private", @@ -25,6 +22,15 @@ "test": "run-p test:*", "test:prettier": "prettier '**/*.{js,jsx,ts,tsx}' --check" }, + "dependencies": { + "@dqbd/tiktoken": "^1.0.7", + "dotenv-safe": "^8.2.0", + "openai-fetch": "^1.2.0", + "p-map": "^6.0.0", + "parse-json": "^7.0.0", + "zod": "^3.21.4", + "zod-validation-error": "^1.3.0" + }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.1.1", "@types/node": "^18.15.13", @@ -54,13 +60,5 @@ "openapi", "guardrails", "plugins" - ], - "dependencies": { - "dotenv-safe": "^8.2.0", - "openai-fetch": "^1.2.0", - "p-map": "^6.0.0", - "parse-json": "^7.0.0", - "zod": "^3.21.4", - "zod-validation-error": "^1.3.0" - } + ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0534870..ad15e5b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,6 +1,9 @@ lockfileVersion: '6.0' dependencies: + '@dqbd/tiktoken': + specifier: ^1.0.7 + version: 1.0.7 dotenv-safe: specifier: ^8.2.0 version: 8.2.0 @@ -165,6 +168,10 @@ packages: to-fast-properties: 2.0.0 dev: true + /@dqbd/tiktoken@1.0.7: + resolution: {integrity: sha512-bhR5k5W+8GLzysjk8zTMVygQZsgvf7W1F0IlL4ZQ5ugjo5rCyiwGM5d8DYriXspytfu98tv59niang3/T+FoDw==} + dev: false + /@esbuild-kit/cjs-loader@2.4.2: resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==} dependencies: diff --git a/src/fluent-scratch.ts b/src/fluent-scratch.ts index cc8fb0c..0c1683b 100644 --- a/src/fluent-scratch.ts +++ b/src/fluent-scratch.ts @@ -15,9 +15,9 @@ async function main() { // given an output as a boolean. // true/false - const ex1 = await $.gpt4( - 'give me a list of character names from star wars' - ).output(z.array(z.string().nonempty())) + const ex1 = await $.gpt4('give me a list of character names from star wars') + .output(z.array(z.string().nonempty())) + .stream() const ex2 = await $.gpt4(`Summarize the following text: {{text}}`) .output(z.string().nonempty()) diff --git a/src/llm.ts b/src/llm.ts index acb68e3..24528c7 100644 --- a/src/llm.ts +++ b/src/llm.ts @@ -94,6 +94,14 @@ export abstract class BaseLLMCallBuilder { } abstract call(input?: TInput): Promise + + // TODO + // abstract stream( + // input: TInput, + // onProgress: types.ProgressFunction + // ): Promise + + // abstract stream(onProgress: types.ProgressFunction): Promise } export abstract class ChatModelBuilder<