I wrote a python package with V1 lib version.
I created an Assistant with associated function calls and documents via online platform UI.
I wrote same apps (telegram bots) using the Assistant via API .
Everithing was working till few days ago
Now, the Assistant has been updated to v2, and the docs has been trasformed into vectors.
My apps does’nt work anymore with my Assistant as they require V2 API libs.
I cannot upgrade to V2 versione as the latest available version is 1.29.x
Even more I could’nt find how to change my code as some methods (retrieve e.g.) seems not anymore available.
here the methods call list I need to convert/check:
If you are using the Python library, just use pip to install a fixed past version (that doesn’t send the v2 header by default), would maintain the function you had. pip install openai<1.20 or such.
There is nothing much to change except the vector store method for file_search that replaces retrieval, and some changes in how certain parameters are passed.
Simply go to “API Reference” and compare the v1 assistants at the bottom of the list of indexes in help to the main assistants.
p.s. may be I’m a little dumb but in The API Reference I find the V1 reference but I cannot find the V2 refererence
All REST calls in the upper references (main assistants) are referring to v1 version afaik
here is where error occours (self.client.beta.threads.runs.create):
async def submit_message(self,assistant_id, thread_id, user_message):
# when a thread is already available create message and run the query
# - create a message
# - run the thread
#@ chck run sul thread
message = self.client.beta.threads.messages.create(thread_id=thread_id, role="user", content=user_message)
return message.id, self.client.beta.threads.runs.create(
thread_id=thread_id,
assistant_id=assistant_id,
instructions=instructions + 'Oggi è '+datetime.now().strftime("%A %d/%m/%Y")
)
and here the error:
openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: “The requested model ‘gpt-4o-2024-05-13’ cannot be used with the Assistants API in v1. Follow the migration guide to upgrade to v2: https://platform.openai.com/docs/assistants/migration.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘model’, ‘code’: ‘unsupported_model’}}
The assistant was create with UI and it works correctly in the openai platform.
My python liv version is 1.30.1
If you really have installed and are running the latest version of the openai library module, you do not need to set any header. You also do not need to set a key on the client if you have an environment variable.
You may have multiple installs, such as not installing openai with administrator rights on your system-wide Python install.
Remove the client parameters from your code. Then diagnose your version faults by running this the same way as your script:
import openai
print(openai.__version__)
'1.30.1'
“Installed in pycharm” is just problematic. You may need to pip uninstall openai in multiple contexts, and then if your python is a system install (program files in windows), only install from administrator command prompt or sudo.