Problem with Assistant - max length 32K even with the gpt-4-1106-preview and trying to get the status I get a passed three arguments error even though I only passed two

Hey all, I keep getting an error in trying to get the run status of a thread.

Here is my call: run_status = client.beta.threads.runs.retrieve(thread.id, run.id)

Here is the error: run_status = client.beta.threads.runs.retrieve(thread.id, run.id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Runs.retrieve() takes 2 positional arguments but 3 were given

I checked and there are values for both thread.id and run.id, and I’m only passing those two arguments, so I’m kind of at a loss.

Bonus, I’m using the gpt-4-1106-preview model (128K context I thought) but if I pass in content greater than 32768 characters I get the following error-

ile “D:<directory>.venv\Lib\site-packages\openai_base_client.py”, line 877, in _request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: ‘1 validation error for Request\nbody → content\n ensure this value has at most 32768 characters (type=value_error.any_str.max_length; limit_value=32768)’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}

Thank you for your time!

1 Like

The first time I’ve had a look at this, and nothing to run it against…

image

The only positional parameter is run_id, others need to be specified.

data you might have retrieved:

created_thread = {
  "id": "thread_abc123",
  "object": "thread",
  "created_at": 1699012949,
  "metadata": {}
}
created_run = {
  "id": "run_example123",
  "object": "thread.run",
  "created_at": 1698107661,
  "assistant_id": "asst_gZ1aOomboBuYWPcXJx4vAYB0",
  "thread_id": "thread_adOpf7Jbb5Abymz0QbwxAh3c",
  "status": "completed",
  "started_at": 1699073476,
  "expires_at": null,
  "cancelled_at": null,
  "failed_at": null,
  "completed_at": 1699073498,
  "last_error": null,
  "model": "gpt-4",
  "instructions": null,
  "tools": [{"type": "retrieval"}, {"type": "code_interpreter"}],
  "file_ids": [],
  "metadata": {}
}

your code:

run_status = client.beta.threads.runs.retrieve(
    run_id = created_run['id'], thread_id = created_thread['thread_id'])
1 Like

That was it. Your fix worked. Thanks :slight_smile:

1 Like

I also see 32K limit error on my runs even though I select gpt-4-1106-preview model: raise self._make_status_error_from_response(err.response) from None openai.BadRequestError: Error code: 400 - {'error': {'message': '1 validation error for Request\nbody -> content\n ensure this value has at most 32768 characters (type=value_error.any_str.max_length; limit_value=32768)', 'type': 'invalid_request_error', 'param': None, 'code': None}}

can you please tell me (if you got it solved) how you also got that solved?

To may knowledge that hasn’t been resolved yet. So in practice, with the API, there is a 32K input limit. 128k is a unicorn for now :slight_smile: I’ve heard of other limitations still out there, my use case is pretty narrow so I haven’t bumped into them.

1 Like

What other way do we have to use the 120k token limitation with their API then?

It just feels like we spent a few hours building an entire use-case around their API to finally discover the specs are not the one announced?

The character limitation is specific to assistants and specific to chat threads and instructions. It does not apply to the retrieval from uploaded files that the AI does on its own.

If you don’t want to engage in OpenAI’s multiple limitations with assistants, you can instead use ChatCompletion endpoint to interact directly with AI models.

1 Like

It (32K limit error) still hasn’t been resolved… wondering if it’s going ever or by design for some unknown reason, which is odd as it should match the selected model specs.

1 Like

Closing this topic as it has a solution.