kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: add tavily example to ai-sdk
rodzic
4e9fa11a15
commit
03bf80e2e0
|
@ -0,0 +1,24 @@
|
|||
import 'dotenv/config'
|
||||
|
||||
import { createAISDKTools } from '@agentic/ai-sdk'
|
||||
import { TavilyClient } from '@agentic/stdlib'
|
||||
import { createOpenAI } from '@ai-sdk/openai'
|
||||
import { generateText } from 'ai'
|
||||
|
||||
async function main() {
|
||||
const tavily = new TavilyClient()
|
||||
const openai = createOpenAI({ compatibility: 'strict' })
|
||||
|
||||
const result = await generateText({
|
||||
model: openai('gpt-4o-mini'),
|
||||
tools: createAISDKTools(tavily),
|
||||
toolChoice: 'required',
|
||||
temperature: 0,
|
||||
system: 'You are a helpful assistant. Be as concise as possible.',
|
||||
prompt: 'What is the latest news in the US right now?'
|
||||
})
|
||||
|
||||
console.log(JSON.stringify(result.toolResults[0], null, 2))
|
||||
}
|
||||
|
||||
await main()
|
|
@ -1,7 +1,7 @@
|
|||
import 'dotenv/config'
|
||||
|
||||
import { createAISDKTools } from '@agentic/ai-sdk'
|
||||
import { WeatherClient } from '@agentic/weather'
|
||||
import { WeatherClient } from '@agentic/stdlib'
|
||||
import { createOpenAI } from '@ai-sdk/openai'
|
||||
import { generateText } from 'ai'
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'dotenv/config'
|
||||
|
||||
import { createAISDKTools } from '@agentic/ai-sdk'
|
||||
import { WeatherClient } from '@agentic/weather'
|
||||
import { WeatherClient } from '@agentic/stdlib'
|
||||
import { createOpenAI } from '@ai-sdk/openai'
|
||||
import { generateText } from 'ai'
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"dependencies": {
|
||||
"@agentic/ai-sdk": "workspace:*",
|
||||
"@agentic/mcp": "workspace:*",
|
||||
"@agentic/weather": "workspace:*",
|
||||
"@agentic/stdlib": "workspace:*",
|
||||
"@ai-sdk/openai": "catalog:",
|
||||
"ai": "catalog:",
|
||||
"exit-hook": "catalog:",
|
||||
|
|
|
@ -172,7 +172,6 @@ export class TavilyClient extends AIFunctionsProvider {
|
|||
max_results: z
|
||||
.number()
|
||||
.int()
|
||||
.positive()
|
||||
.default(5)
|
||||
.optional()
|
||||
.describe('Max number of search results to return.')
|
||||
|
|
|
@ -269,9 +269,9 @@ importers:
|
|||
'@agentic/mcp':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/mcp
|
||||
'@agentic/weather':
|
||||
'@agentic/stdlib':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/weather
|
||||
version: link:../../packages/stdlib
|
||||
'@ai-sdk/openai':
|
||||
specifier: 'catalog:'
|
||||
version: 1.3.4(zod@3.24.2)
|
||||
|
|
Ładowanie…
Reference in New Issue