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

Assistant : Error reading thread run response #412

Closed
geoffreyfourmis opened this issue Nov 17, 2023 · 8 comments
Closed

Assistant : Error reading thread run response #412

geoffreyfourmis opened this issue Nov 17, 2023 · 8 comments

Comments

@geoffreyfourmis
Copy link

geoffreyfourmis commented Nov 17, 2023

Hello,

Using v0.18.1 just released with the #408 by @vacuityv , I was trying to run an assistant's thread (using function). Maybe I'm missing something but until now I'm unable de complete the run.

Here is the code :

        // Create thread with one message
        MessageRequest messageRequest = MessageRequest.builder()
                .content(text)
                .build();
        ThreadRequest threadRequest = ThreadRequest.builder()
                .messages(Collections.singletonList(messageRequest))
                .build();
        Thread thread = service.createThread(threadRequest);

        // run thread
        RunCreateRequest runCreateRequest = RunCreateRequest.builder()
                .assistantId(ASSISTANT_ID)
                .build();

        // error here
        Run run = service.createRun(thread.getId(), runCreateRequest);

Here is the error I got

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.Class` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 25, column: 23] (through reference chain: com.theokanning.openai.runs.Run["tools"]->java.util.ArrayList[1]->com.theokanning.openai.assistants.Tool["function"]->com.theokanning.openai.completion.chat.ChatFunction["parameters"])

full stack trace :
stack_trace.txt

If I manually call URLs here is the JSON response, like the stack trace says the pb is on tools->functions[1]->parameters

{
    "id": "run_ID",
  (...)
    "tools": [
        {
            "type": "retrieval"
        },
        {
            "type": "function",
            "function": {
                "name": "function_test1",
                "description": "my description ",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "param_test1": {
                            "type": "string",
                            "description": "Param test1"
                        }
                    },
                    "required": [
                        "param_test1"
                    ]
                }
            }
        }
    ],
    (...)
}

full response :
manual_call_response.json

In the source code I found that it is ChatFunction used :

public class ChatFunction {
 (...)

    /**
     * The parameters the functions accepts.
     */
    @JsonProperty("parameters")
    private Class<?> parametersClass;

I'm trying to find the solution by myself, without success until now.

@vacuityv
Copy link
Contributor

vacuityv commented Nov 17, 2023 via email

@vacuityv
Copy link
Contributor

vacuityv commented Nov 17, 2023 via email

@geoffreyfourmis
Copy link
Author

geoffreyfourmis commented Nov 17, 2023

Thanks you for the quick answers, I just tried using the simple weather function example from Open AI assistant and I got the same error.

I was able to complete the call localy & temporary by ignoring the property parameters in ChatFunction

@JsonIgnoreProperties(value={ "parameters" })
public class ChatFunction {

Because I don't understand how jackson is suppose de deserialize this :

    @JsonProperty("parameters")
    private Class<?> parametersClass;

@vacuityv
Copy link
Contributor

@geoffreyfourmis I checked and it's because the function is different from the chat-function. I said here:

#390

image image

And I think it nned to be fixed by @TheoKanning

@vacuityv
Copy link
Contributor

@geoffreyfourmis I make a pr for this: #415. You can get more infomation about function in this file: AssistantFunctionTest. And we need @TheoKanning to review and merge it.

@TheoKanning
Copy link
Owner

Fixed in 0.18.2

@geoffreyfourmis
Copy link
Author

Thanks both of you, it's working great

@vacuityv
Copy link
Contributor

@geoffreyfourmis Happy that was fixed. You are welcome.

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

3 participants