chatgpt-api/examples/genkit/weather.ts

37 wiersze
781 B
TypeScript
Czysty Zwykły widok Historia

2024-06-02 07:30:50 +00:00
#!/usr/bin/env node
import 'dotenv/config'
2024-06-07 05:42:55 +00:00
import { WeatherClient } from '@agentic/stdlib'
import { createGenkitTools } from '@agentic/stdlib/genkit'
2024-06-02 07:30:50 +00:00
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,
2024-06-02 08:06:45 +00:00
tools: createGenkitTools(weather),
2024-06-02 07:30:50 +00:00
history: [
{
role: 'system',
content: [
{
2024-06-02 22:30:39 +00:00
text: 'You are a helpful assistant. Be as concise as possible.'
2024-06-02 07:30:50 +00:00
}
]
}
],
2024-06-02 08:06:45 +00:00
prompt: 'What is the weather in San Francisco?'
2024-06-02 07:30:50 +00:00
})
console.log(result)
}
await main()