Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Assistant creation returns an error on tools input #467

Open
Grebyn35 opened this issue Feb 16, 2024 · 1 comment
Open

Assistant creation returns an error on tools input #467

Grebyn35 opened this issue Feb 16, 2024 · 1 comment

Comments

@Grebyn35
Copy link

Grebyn35 commented Feb 16, 2024

I think OpenAi has changed some parameter when creating an assistant and setting tools.

When creating an assistant:

AssistantRequest assistantRequest = AssistantRequest.builder()
                .name("test")
                .model("gpt-4-0125-preview")
                .description("")
                .instructions("")
                .tools(List.of(new Tool(AssistantToolsEnum.CODE_INTERPRETER, null), new Tool(AssistantToolsEnum.RETRIEVAL, null)))
                .fileIds(new ArrayList<>())
                .build();

An error occurs:

{
  "error": {
    "message": "10 validation errors for Request\nbody -> tools -> 0 -> function\n  extra fields not permitted (type=value_error.extra)\nbody -> tools -> 0 -> type\n  unexpected value; permitted: <ToolTypeParam.RETRIEVAL: 'retrieval'> (type=value_error.const; given=code_interpreter; permitted=(<ToolTypeParam.RETRIEVAL: 'retrieval'>,))\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=code_interpreter; permitted=(<ToolTypeParam.FUNCTION: 'function'>,))\nbody -> tools -> 0 -> function\n  none is not an allowed value (type=type_error.none.not_allowed)\nbody -> tools -> 1 -> type\n  unexpected value; permitted: <ToolTypeParam.CODE_INTERPRETER: 'code_interpreter'> (type=value_error.const; given=retrieval; permitted=(<ToolTypeParam.CODE_INTERPRETER: 'code_interpreter'>,))\nbody -> tools -> 1 -> function\n  extra fields not permitted (type=value_error.extra)\nbody -> tools -> 1 -> function\n  extra fields not permitted (type=value_error.extra)\nbody -> tools -> 1 -> type\n  unexpected value; permitted: <ToolTypeParam.FUNCTION: 'function'> (type=value_error.const; given=retrieval; permitted=(<ToolTypeParam.FUNCTION: 'function'>,))\nbody -> tools -> 1 -> function\n  none is not an allowed value (type=type_error.none.not_allowed)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

Might be because tools has null as a parameter, and it doesnt accept it unless its AssistantToolsEnum.FUNCTION?

@avntsnghchgh
Copy link

I had the same issue, here is the fix:

https://community.openai.com/t/create-assistants-api-broken-since-2-16-2024/629996

move the required after properties but within parameters like below:
{
"type": "function",
"function": {
"name": "getNickname",
"description": "Get the nickname of a city",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "The city and state e.g. San Francisco, CA"},
},
"required": ["location"]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants