Travis Fischer 2023-05-26 17:58:46 -07:00
rodzic b5b5063354
commit e085215b11
5 zmienionych plików z 7 dodań i 9 usunięć

Wyświetl plik

@ -6,17 +6,15 @@ import { Agentic } from '../src'
dotenv.config() dotenv.config()
export async function sentimentAgent() { export async function main() {
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! }) const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
const $ = new Agentic({ openai }) const $ = new Agentic({ openai })
const article = await $.gpt4( const article = await $.gpt3(
'I want an article that seems like it was on Wikipedia. It should be 500 characters long.' 'Generate a fake, short Wikipedia article.'
).call() ).call()
console.log('got an article', article) const example = await $.gpt3(
const example = await $.gpt4(
`You are a wikipedia article summarizer. However, `You are a wikipedia article summarizer. However,
you return a bunch of important information about the article in JSON format. you return a bunch of important information about the article in JSON format.
You're really good at coming up with semantic labels for the information you find. You're really good at coming up with semantic labels for the information you find.
@ -27,10 +25,10 @@ export async function sentimentAgent() {
.output( .output(
z.object({ z.object({
title: z.string(), title: z.string(),
serializedJsonSummary: z.string() summary: z.string()
}) })
) )
// .assert((output) => JSON.parse(output.serializedJsonSummary)) // .assert((output) => JSON.parse(output.summary))
.call({ .call({
article article
}) })
@ -38,4 +36,4 @@ export async function sentimentAgent() {
console.log('example', example) console.log('example', example)
} }
sentimentAgent() main()