chatgpt-api/examples/dexter/weather.ts

23 wiersze
636 B
TypeScript
Czysty Zwykły widok Historia

2024-06-02 00:34:25 +00:00
#!/usr/bin/env node
import 'dotenv/config'
2024-06-02 08:16:23 +00:00
import { ChatModel, createAIRunner } from '@dexaai/dexter'
2024-06-02 00:34:25 +00:00
2024-06-02 02:04:13 +00:00
import { WeatherClient } from '../../src/index.js'
2024-06-02 08:06:45 +00:00
import { createDexterFunctions } from '../../src/sdks/dexter.js'
2024-06-02 00:34:25 +00:00
async function main() {
2024-06-02 08:16:23 +00:00
const weather = new WeatherClient()
2024-06-02 00:34:25 +00:00
2024-06-02 08:16:23 +00:00
const runner = createAIRunner({
chatModel: new ChatModel({ params: { model: 'gpt-4o', temperature: 0 } }),
functions: createDexterFunctions(weather),
systemMessage: 'You are a weather assistant. Be as concise as possible.'
2024-06-02 00:34:25 +00:00
})
2024-06-02 08:16:23 +00:00
const result = await runner('What is the weather in San Francisco?')
console.log(result)
2024-06-02 00:34:25 +00:00
}
2024-06-02 02:04:13 +00:00
await main()