2023-06-01 01:53:09 +00:00
|
|
|
import 'dotenv/config'
|
2023-05-27 00:38:55 +00:00
|
|
|
import { OpenAIClient } from 'openai-fetch'
|
|
|
|
import { z } from 'zod'
|
|
|
|
|
|
|
|
import { Agentic } from '../src'
|
|
|
|
|
2023-05-27 01:15:42 +00:00
|
|
|
export async function main() {
|
2023-05-27 00:38:55 +00:00
|
|
|
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
|
|
|
|
const $ = new Agentic({ openai })
|
|
|
|
|
|
|
|
const example = await $.gpt4(
|
2023-05-27 01:10:48 +00:00
|
|
|
`You are an expert sentiment-labelling assistant. Label the following texts as positive or negative: \n{{#texts}}- {{.}}\n{{/texts}}`
|
2023-05-27 00:38:55 +00:00
|
|
|
)
|
|
|
|
.input(z.object({ texts: z.string().array() }))
|
|
|
|
.output(z.array(z.object({ text: z.string(), label: z.string() })))
|
2023-06-07 06:43:15 +00:00
|
|
|
.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' }
|
|
|
|
])
|
2023-05-27 00:38:55 +00:00
|
|
|
.call({
|
|
|
|
texts: [
|
|
|
|
'I went to this place and it was just so awful.',
|
|
|
|
'I had a great time.',
|
|
|
|
'I had a terrible time.',
|
2023-05-27 01:04:18 +00:00
|
|
|
'Food poisoning...'
|
2023-05-27 00:38:55 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log('example', example)
|
|
|
|
}
|
|
|
|
|
2023-05-27 01:15:42 +00:00
|
|
|
main()
|