-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Open
Labels
Description
Please can someone explain , im not sure why i get this error
Error [AI_APICallError]: Invalid schema for function 'GMAIL_CREATE_EMAIL_DRAFT': schema must be a JSON Schema of 'type: "object"', got 'type: "None"'.] {
cause: undefined,
url: 'https://api.openai.com/v1/responses',
requestBodyValues: [Object],
statusCode: 400,
responseHeaders: [Object],
responseBody: '{\n' +
' "error": {\n' +
` "message": "Invalid schema for function 'GMAIL_CREATE_EMAIL_DRAFT': schema must be a JSON Schema of 'type: \\"object\\"', got 'type: \\"None\\"'.",\n` +
' "type": "invalid_request_error",\n' +
' "param": "tools[0].parameters",\n' +
' "code": "invalid_function_parameters"\n' +
' }\n' +
'}',
isRetryable: false,
data: [Object]
}
POST /api/chat 200 in 2582ms
import { NextRequest } from 'next/server';
import { Composio } from '@composio/core';
import { VercelProvider } from '@composio/vercel';
import { streamText, convertToModelMessages, UIMessage, type Tool } from 'ai';
import { openai } from '@ai-sdk/openai';
export const maxDuration = 30;
const composio = new Composio({
apiKey: process.env.COMPOSIO_API_KEY,
provider: new VercelProvider(),
});
export async function POST(req: NextRequest) {
const { messages }: { messages: UIMessage[] } = await req.json();
const userId = '4b5f4869-8748-4802-a50e-e75f055dbf0b';
const composioTools = await composio.tools.get(userId, {
toolkits: ['GMAIL'],
});
const result = await streamText({
model: openai('gpt-4'),
messages: convertToModelMessages(messages),
tools: composioTools,
});
return result.toUIMessageStreamResponse();
}