route
This commit is contained in:
parent
d4eb9ae899
commit
17436862e0
@ -83,20 +83,35 @@ export async function POST(request: NextRequest) {
|
||||
const toolsToPass = agent.tools || {}
|
||||
console.log(`[chat] Tools available for agent ${agentId}:`, Object.keys(toolsToPass))
|
||||
|
||||
// TEMPORARY: Disable tools for debugging
|
||||
// Remove once tool calling issue is resolved
|
||||
const toolsForStreaming = Object.keys(toolsToPass).length > 0 ? undefined : toolsToPass
|
||||
if (Object.keys(toolsToPass).length > 0) {
|
||||
console.log(`[chat] WARNING: Tools are defined but being disabled temporarily due to CPU limit issue`)
|
||||
}
|
||||
|
||||
// Stream response from agent
|
||||
console.log(`[chat] Starting streamText for agent ${agentId}`)
|
||||
const startTime = Date.now()
|
||||
|
||||
const result = streamText({
|
||||
model,
|
||||
system: agent.systemPrompt,
|
||||
tools: toolsToPass,
|
||||
tools: toolsForStreaming, // Temporarily disabled
|
||||
messages,
|
||||
temperature: agent.temperature,
|
||||
// Note: maxTokens is not used in streamText - it uses maxRetries, retry logic, etc
|
||||
onFinish: (event) => {
|
||||
console.log(`[chat] Response completed for agent ${agentId}`)
|
||||
const duration = Date.now() - startTime
|
||||
console.log(`[chat] Response completed for agent ${agentId}, duration: ${duration}ms`)
|
||||
if (event.usage) {
|
||||
console.log(`[chat] Token usage - input: ${event.usage.inputTokens}, output: ${event.usage.outputTokens}`)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// Return as text stream response (Server-Sent Events format)
|
||||
console.log(`[chat] Converting to text stream for agent ${agentId}`)
|
||||
return result.toTextStreamResponse()
|
||||
} catch (error) {
|
||||
console.error('[chat] Error:', error)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user