kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
37 wiersze
781 B
JavaScript
37 wiersze
781 B
JavaScript
#!/usr/bin/env node
|
|
import 'dotenv/config'
|
|
|
|
import { WeatherClient } from '@agentic/stdlib'
|
|
import { createGenkitTools } from '@agentic/stdlib/genkit'
|
|
import { generate } from '@genkit-ai/ai'
|
|
import { configureGenkit } from '@genkit-ai/core'
|
|
import { gpt4o, openAI } from 'genkitx-openai'
|
|
|
|
async function main() {
|
|
const weather = new WeatherClient()
|
|
|
|
configureGenkit({
|
|
plugins: [openAI()]
|
|
})
|
|
|
|
const result = await generate({
|
|
model: gpt4o,
|
|
tools: createGenkitTools(weather),
|
|
history: [
|
|
{
|
|
role: 'system',
|
|
content: [
|
|
{
|
|
text: 'You are a helpful assistant. Be as concise as possible.'
|
|
}
|
|
]
|
|
}
|
|
],
|
|
prompt: 'What is the weather in San Francisco?'
|
|
})
|
|
|
|
console.log(result)
|
|
}
|
|
|
|
await main()
|