From b4e5f405ed824d57d7398f862ad7202cb16eaaa5 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Fri, 26 May 2023 18:30:45 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- legacy/examples/scratch.ts | 19 +++++++++++++++++++ legacy/examples/sentiment.ts | 5 ----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 legacy/examples/scratch.ts diff --git a/legacy/examples/scratch.ts b/legacy/examples/scratch.ts new file mode 100644 index 00000000..df3ed199 --- /dev/null +++ b/legacy/examples/scratch.ts @@ -0,0 +1,19 @@ +import dotenv from 'dotenv-safe' +import { OpenAIClient } from 'openai-fetch' +import { z } from 'zod' + +import { Agentic } from '../src' + +dotenv.config() + +async function main() { + const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! }) + const $ = new Agentic({ openai }) + + const ex1 = await $.gpt4(`generate fake data`) + // .output(z.object({ foo: z.string(), bar: z.number() })) + .call() + console.log(ex1) +} + +main() diff --git a/legacy/examples/sentiment.ts b/legacy/examples/sentiment.ts index 7095e7ea..f88310dc 100644 --- a/legacy/examples/sentiment.ts +++ b/legacy/examples/sentiment.ts @@ -14,7 +14,6 @@ export async function main() { `You are an expert sentiment-labelling assistant. Label the following texts as positive or negative: \n{{#texts}}- {{.}}\n{{/texts}}` ) .input(z.object({ texts: z.string().array() })) - // TODO: label should be a union of literals .output(z.array(z.object({ text: z.string(), label: z.string() }))) .examples([ { input: 'The food was digusting', output: 'negative' }, @@ -22,10 +21,6 @@ export async function main() { { input: 'Recommended', output: 'positive' }, { input: 'The waiter was rude', output: 'negative' } ]) - // .assert((output) => output.filter(({ label }) => - // !['positive', 'negative'].includes(label) - // ).length === 0 - // }) .call({ texts: [ 'I went to this place and it was just so awful.',