|
1 | 1 | import { openai, createOpenAI } from '@ai-sdk/openai'; |
2 | 2 | import { createAnthropic } from '@ai-sdk/anthropic'; |
3 | | -import { streamText, tool } from 'ai'; |
| 3 | +import { streamText } from 'ai'; |
4 | 4 | import { z } from 'zod'; |
5 | 5 | import { NextResponse } from 'next/server'; |
6 | 6 | import { checkRateLimit } from '@/lib/rate-limit'; |
@@ -184,58 +184,6 @@ export async function POST(req: Request) { |
184 | 184 | system: 'You are a helpful assistant. Respond to the user in Markdown format.', |
185 | 185 | model: getModelProvider(model, customApiKey), |
186 | 186 | messages, |
187 | | - tools: { |
188 | | - weather: tool({ |
189 | | - description: 'Get the weather in a location (fahrenheit)', |
190 | | - parameters: z.object({ |
191 | | - location: z |
192 | | - .string() |
193 | | - .describe('The location to get the weather for'), |
194 | | - }), |
195 | | - execute: async ({ location }) => { |
196 | | - try { |
197 | | - // In a real app, this would call a weather API |
198 | | - const temperature = Math.round( |
199 | | - Math.random() * (90 - 32) + 32, |
200 | | - ); |
201 | | - return { |
202 | | - location, |
203 | | - temperature, |
204 | | - }; |
205 | | - } catch (error) { |
206 | | - console.error('Weather tool error:', error); |
207 | | - throw new Error('Failed to get weather data'); |
208 | | - } |
209 | | - }, |
210 | | - }), |
211 | | - convertFahrenheitToCelsius: tool({ |
212 | | - description: |
213 | | - 'Convert a temperature in fahrenheit to celsius', |
214 | | - parameters: z.object({ |
215 | | - temperature: z |
216 | | - .number() |
217 | | - .describe( |
218 | | - 'The temperature in fahrenheit to convert', |
219 | | - ), |
220 | | - }), |
221 | | - execute: async ({ temperature }) => { |
222 | | - try { |
223 | | - const celsius = Math.round( |
224 | | - (temperature - 32) * (5 / 9), |
225 | | - ); |
226 | | - return { |
227 | | - celsius, |
228 | | - }; |
229 | | - } catch (error) { |
230 | | - console.error( |
231 | | - 'Temperature conversion error:', |
232 | | - error, |
233 | | - ); |
234 | | - throw new Error('Failed to convert temperature'); |
235 | | - } |
236 | | - }, |
237 | | - }), |
238 | | - }, |
239 | 187 | onFinish: ({ usage, finishReason }) => { |
240 | 188 | // Log completion metrics |
241 | 189 | console.log('Chat completion:', { |
|
0 commit comments