From f1ea43cb4fb5f747748a539fa0ebfc4ff4781653 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Fri, 26 May 2023 18:04:18 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- legacy/examples/sentiment.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/legacy/examples/sentiment.ts b/legacy/examples/sentiment.ts index 07f3e328..f8fa25ca 100644 --- a/legacy/examples/sentiment.ts +++ b/legacy/examples/sentiment.ts @@ -10,19 +10,17 @@ export async function sentimentAgent() { const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! }) const $ = new Agentic({ openai }) - const examples = [ - { input: 'The food was digusting', output: 'negative' }, - { input: 'We had a fantastic night', output: 'positive' }, - { input: 'Recommended', output: 'positive' }, - { input: 'The waiter was rude', output: 'negative' } - ] - const example = await $.gpt4( - `You are a sentiment-labelling assistant. Label the following texts as positive or negative: {{texts}}` + `You are an expert sentiment-labelling assistant. Label the following texts as positive or negative: {{texts}}` ) .input(z.object({ texts: z.string().array() })) .output(z.array(z.object({ text: z.string(), label: z.string() }))) - .examples(examples) + .examples([ + { input: 'The food was digusting', output: 'negative' }, + { input: 'We had a fantastic night', output: 'positive' }, + { input: 'Recommended', output: 'positive' }, + { input: 'The waiter was rude', output: 'negative' } + ]) // .assert((output) => output.filter(({ label }) => // !['positive', 'negative'].includes(label) // ).length === 0 @@ -32,7 +30,7 @@ export async function sentimentAgent() { 'I went to this place and it was just so awful.', 'I had a great time.', 'I had a terrible time.', - 'I had a good time.' + 'Food poisoning...' ] })