datastax / astra-assistants-api

Drop in replacement for the OpenAI Assistants API
Apache License 2.0
140 stars 15 forks source link

client.beta.threads.create_and_run() is not working #69

Closed runninghare closed 1 week ago

runninghare commented 2 weeks ago

This can be repliated with a simple piece of snippet on any known assitant Id.

thread = client.beta.threads.create()
message = client.beta.threads.messages.create(
    thread_id=thread.id,
    role="user",
    content="I need to solve the equation `3x + 11 = 14`. Can you help me?",
)
result = client.beta.threads.create_and_run(assistant_id="asst_CspjsbeH61kT_7vCMH5ZU9Jb4GkDPiQZ", thread=thread)

The error message is: openai.InternalServerError: Error code: 500 - {'message': '1 validation error for ThreadObject\ncreated_at\n Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.8/v/int_type'}

It looks like client.beta.threads.create_and_run is sending a POST request to '/threads/runs', however on the server there seems to be a conflict on routing. The actual request was sent to:

@router.post(
    "/threads/{thread_id}",
    responses={
        200: {"model": ThreadObject, "description": "OK"},
    },
    tags=["Assistants"],
    summary="Modifies a thread.",
    response_model_by_alias=True,
    response_model=None
)

see: .../packages/openai/resources/beta/threads/threads.py

phact commented 2 weeks ago

@runninghare thanks for opening this issue, I'll have a look!

phact commented 2 weeks ago

Repro and fix here - https://github.com/datastax/astra-assistants-api/tree/issue-69

pesky route order issue.

Will cut a release and ship soon, likely tonight.

phact commented 2 weeks ago

Fixed in v0.2.28 shipped to docker hub and deployed to service