hello, I seem to have encountered an error while adding retrievals to my chatbot. This didn’t happen before, and i did not change any code. Here’s the error:
Error Response: {
“error”: {
“message”: “5 validation errors for Request\nbody → tools → 0 → type\n unexpected value; permitted: <ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’> (type=value_error.const; given=retrieval; permitted=(<ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’>,))\nbody → tools → 0 → function\n extra fields not permitted (type=value_error.extra)\nbody → tools → 0 → function\n extra fields not permitted (type=value_error.extra)\nbody → tools → 0 → type\n unexpected value; permitted: <ToolTypeParam.FUNCTION: ‘function’> (type=value_error.const; given=retrieval; permitted=(<ToolTypeParam.FUNCTION: ‘function’>,))\nbody → tools → 0 → function\n none is not an allowed value (type=type_error.none.not_allowed)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
Is this create assistant or modify assistant? Run?
How long since the code did this successfully? You’ve updated, or not updated, openai libraries?
I just did an enable or disable in the playground. Works. You can try the same there.
your message
5 validation errors for Request
body → tools → 0 → type
unexpected value; permitted: <ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’> (type=value_error.const; given=retrieval; permitted=(<ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’>,))
body → tools → 0 → function
extra fields not permitted (type=value_error.extra)
body → tools → 0 → function
extra fields not permitted (type=value_error.extra)
body → tools → 0 → type
unexpected value; permitted: <ToolTypeParam.FUNCTION: ‘function’> (type=value_error.const; given=retrieval; permitted=(<ToolTypeParam.FUNCTION: ‘function’>,))
body → tools → 0 → function
none is not an allowed value (type=type_error.none.not_allowed)
looking at openai.yaml, I don’t see any pull that is in this wheelhouse, although yaml seems closer to documentation than currently-operating API version.
AssistantToolsRetrieval:
type: object
title: Retrieval tool
properties:
type:
type: string
description: "The type of tool being defined: `retrieval`"
enum: ["retrieval"]
required:
- type
Where AssistantToolsCode is specified, it is always accompanied by the others including retrieval:
tools:
description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
nullable: true
type: array
maxItems: 20
items:
oneOf:
- $ref: "#/components/schemas/AssistantToolsCode"
- $ref: "#/components/schemas/AssistantToolsRetrieval"
- $ref: "#/components/schemas/AssistantToolsFunction"
x-oaiExpandable: true
Hi, thanks for the reply. I’m creating an assistant. I’m also not using any openAI libraries as I’m coding in c#, so I’m using http methods to do requests.
I’m having the same issue. Was using the assistants API successfully for weeks and didn’t change any code, but started noticing an error about one to two hours ago. I’m using “gpt-4-turbo-preview” as the model.
Error code: 400 - {‘error’: {‘message’: “10 validation errors for Request\nbody → tools → 3 → type\n unexpected value; permitted: <ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’> (type=value_error.const; given=function; permitted=(<ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’>,))\nbody → tools → 3 → function\n extra fields not permitted (type=value_error.extra)\nbody → tools → 3 → type\n unexpected value; permitted: <ToolTypeParam.RETRIEVAL: ‘retrieval’> (type=value_error.const; given=function; permitted=(<ToolTypeParam.RETRIEVAL: ‘retrieval’>,))\nbody → tools → 3 → function\n extra fields not permitted (type=value_error.extra)\nbody → tools → 3 → function → return\n extra fields not permitted (type=value_error.extra)\nbody → tools → 4 → type\n unexpected value; permitted: <ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’> (type=value_error.const; given=function; permitted=(<ToolTypeParam.CODE_INTERPRETER: ‘code_interpreter’>,))\nbody → tools → 4 → function\n extra fields not permitted (type=value_error.extra)\nbody → tools → 4 → type\n unexpected value; permitted: <ToolTypeParam.RETRIEVAL: ‘retrieval’> (type=value_error.const; given=function; permitted=(<ToolTypeParam.RETRIEVAL: ‘retrieval’>,))\nbody → tools → 4 → function\n extra fields not permitted (type=value_error.extra)\nbody → tools → 4 → function → return\n extra fields not permitted (type=value_error.extra)”, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}
I started getting the same error since last night…no changes, everything was working correctly prior to that…I also tried the below with a simple example and it is now throwing an error
{
“instructions”: “You are a personal math tutor. When asked a question, write and run Python code to answer the question.”,
“name”: “Math Tutor”,
“tools”: [
{
“type”: “function”,
“function”: {
“name”: “getCustomer”,
“description”: “Get End customer details”,
“parameters”: {
“type”: “object”,
“properties”: {
“customerId”: {
“type”: “number”,
“description”: “the end customer Id in the platform.”
}
}
},
“required”: [ “customerId” ]
}
}
],
“model”: “gpt-4”
}
The required field was in the wrong location, previously there was no validation, it seems like validation was recently added which caused this api to break…moving the required field to the right location fixed the issue
Hey folks, happy to take a look at this, please share the actual request you are using to create your assistant, otherwise it is very hard to debug / diagnose.
Thanks for replying, Logan. I had defined assistant_tools with details on the return values of the tool function like this. I looked again in the documentation and Python SDK materials in the cookbook and I don’t see return values specified anywhere, so maybe it’s something that ChatGPT had just added in when I asked it to write a JSON definition of my tool function. I can’t remember why I did this initially. Anyway, removing the return values seems to fix the problem, but does raise the question of whether defining return values in the JSON would be useful to the assistant.
CAUSES ERRORS:
assistant_tools = [
{
"type": "function",
"function": {
"name": "import_property_from_address",
"description": "Imports property data from a given address. It creates or updates a Property object in the database with these details.",
"parameters": {
"type": "object",
"properties": {
"address": {
"type": "string",
"description": "The address of the property to import."
}
},
"required": ["address"]
},
"return": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"description": "Indicates whether the property was successfully imported."
},
"property_uuid": {
"type": "string",
"description": "The UUID of the property object created or updated, if the import was successful."
}
},
"required": ["success", "property_uuid"]
}
}
}
]
NO ERRORS:
assistant_tools = [
{
"type": "function",
"function": {
"name": "import_property_from_address",
"description": "Imports property data from a given address. It creates or updates a Property object in the database with these details.",
"parameters": {
"type": "object",
"properties": {
"address": {
"type": "string",
"description": "The address of the property to import."
}
},
"required": ["address"]
},
# removed return definition
}
}
]
string url = “https://api.openai.com/v1/assistants”;
var requestData = new
{
instructions = “You are a coach who is an expert in creating role-playing scenarios related to the uploaded document.”,
name = “Role-Playing Expert Coach”,
tools = new ResponseData.AssistantData.Tool
{
new ResponseData.AssistantData.Tool {Type = “retrieval”}
},
file_ids = JsonHelper.FormatFileIdsAsJsonArray(fileIds), // Use the manually formatted JSON array string
model = _AIModel.Model
};
public class AssistantData
{
public string instructions;
public string name;
public Tool tools;
public string file_ids;
public string model;
[System.Serializable]
public class Tool
{
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("function")]
public Function Function { get; set; }
}
Hi all, we did recently tighten up the validation logic here, apologies for the issues. We now check for unknown fields in each tool definition and disallow them. This was a bug in our original validation logic that we intended to fix.
@CheongFan it looks like you might be passing “function: null” when sending us code_interpreter or retrieval tools I.e.
{
“type”: “code_interpreter”,
“function”: null
}
Would you be able to update your code to skip the “function” field if it doesn’t exist?