#Typing Error with AI Tools
6 messages · Page 1 of 1 (latest)
my code looks like:
javascript
const functionDefinitions = [
{
type: "function",
function: {
name: "searchGoogle",
description:
"Useful for acquiring answers via a Google search...",
parameters: {
type: "object",
properties: {
question: {
type: "string"
}
},
required: ["question"]
}
}
},
{ type: "retrieval" }
];
const existingArticle = await openai.files.create({
file: await fetch(url),
purpose: "assistants"
});
// Update the assistant with the new url
await openai.beta.assistants.update(assistantID, {
tools: functionDefinitions, // <---- Typing error here
file_ids: [existingArticle.id]
});
The error I get:
Type '{ type: string; function: { name: string; description: string; parameters: { type: string; properties: { question: { type: string; }; }; required: string[]; }; }; } | { type: string; function?: undefined; }' is not assignable to type 'AssistantToolsCode | AssistantToolsRetrieval | AssistantToolsFunction'.
Type '{ type: string; function: { name: string; description: string; parameters: { type: string; properties: { question: { type: string; }; }; required: string[]; }; }; }' is not assignable to type 'AssistantToolsCode | AssistantToolsRetrieval | AssistantToolsFunction'.
Type '{ type: string; function: { name: string; description: string; parameters: { type: string; properties: { question: { type: string; }; }; required: string[]; }; }; }' is not assignable to type 'AssistantToolsFunction'.
Types of property 'type' are incompatible.
Type 'string' is not assignable to type '"function"'.
as far as I can tell, everything seems typed correctly; and github copilot agrees ...
I have no clue what this is but I just copy pasted it with chatGPT
// Define the functionDefinitions array with a type annotation to match expected tool types
const functionDefinitions: (AssistantToolsCode | AssistantToolsRetrieval | AssistantToolsFunction)[] = [
{
type: "function", // Ensure 'type' exactly matches the expected string for the type
function: {
name: "searchGoogle",
description: "Useful for acquiring answers via a Google search...",
parameters: {
type: "object",
properties: {
question: {
type: "string"
}
},
required: ["question"]
}
}
},
{
type: "retrieval" // Make sure this type also conforms to the expected types
}
// ... You can add more tool definitions here if needed
];