chatgpt-api/examples/dexter/weather.ts

26 wiersze
667 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({
2024-06-03 22:09:28 +00:00
chatModel: new ChatModel({
params: { model: 'gpt-4o', temperature: 0 }
// debug: true
}),
2024-06-02 08:16:23 +00:00
functions: createDexterFunctions(weather),
2024-06-02 22:30:39 +00:00
systemMessage: 'You are a helpful 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()