Azure / AI-in-a-Box

AI-in-a-Box leverages the expertise of Microsoft across the globe to develop and provide AI and ML solutions to the technical community. Our intent is to present a curated collection of solution accelerators that can help engineers establish their AI/ML environments and solutions rapidly and with minimal friction.
MIT License
526 stars 179 forks source link

[BUG] Issue with ... gen-ai/Assistants/api-in-a-box/assistant-math_tutor/example #47

Closed Kee2u closed 8 months ago

Kee2u commented 8 months ago

Solution Accelerators This repository contains multiple solution accelerators. Please tell us which ones are involved in your report. (Replace the space in between square brackets with an x)

Describe the bug Im getting a resource not found when trying to connect to the model. I followed the .env example and validated that the parameters were getting read properly.

OPENAI_URI=https://NAME.openai.azure.com/ BASE_URL=https://NAME.openai.azure.com/openai OPENAI_KEY=xxxx OPENAI_VERSION=2023-07-01-preview OPENAI_GPT_DEPLOYMENT=gpt-4

These were my parameters. I named the deployment the same as the model. I tried models in US East2 and Sweden Central. To Reproduce Steps to reproduce the behavior:

  1. Go to (https://github.com/Azure/AI-in-a-Box/tree/main/gen-ai/Assistants/api-in-a-box/math_tutor)
  2. Clone it to your local machine
  3. Install the packages from requirements.txt
  4. Create the env file based on the example provided and put it in the api-in-a-box folder
  5. Run all till the cell "Create an Assistant and a Thread". Thats where im getting the error
  6. This is the error:

  7. NotFoundError Traceback (most recent call last) Cell In[16], line 1 ----> 1 assistant = client.beta.assistants.create( 2 name="Math Tutor", 3 instructions="You are a personal math tutor. Write and run code to answer math questions.", 4 tools=[{"type": "code_interpreter"}], 5 model=api_deployment_name, 6 ) 8 thread = client.beta.threads.create()

File c:\Users\testuser\AppData\Local\anaconda3\envs\Assistants\Lib\site-packages\openai\resources\beta\assistants\assistants.py:108, in Assistants.create(self, model, description, file_ids, instructions, metadata, name, tools, extra_headers, extra_query, extra_body, timeout) 70 """ 71 Create an assistant with a model and instructions. 72 (...) 105 timeout: Override the client-level default timeout for this request, in seconds 106 """ 107 extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})} --> 108 return self._post( 109 "/assistants", 110 body=maybe_transform( 111 { 112 "model": model, 113 "description": description, 114 "file_ids": file_ids, 115 "instructions": instructions, 116 "metadata": metadata, 117 "name": name, 118 "tools": tools, 119 }, 120 assistant_create_params.AssistantCreateParams, 121 ), 122 options=make_request_options( 123 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout 124 ), 125 cast_to=Assistant, 126 )

File c:\Users\testuser\AppData\Local\anaconda3\envs\Assistants\Lib\site-packages\openai_base_client.py:1200, in SyncAPIClient.post(self, path, cast_to, body, options, files, stream, stream_cls) 1186 def post( 1187 self, 1188 path: str, (...) 1195 stream_cls: type[_StreamT] | None = None, 1196 ) -> ResponseT | _StreamT: 1197 opts = FinalRequestOptions.construct( 1198 method="post", url=path, json_data=body, files=to_httpx_files(files), **options 1199 ) -> 1200 return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))

File c:\Users\testuser\AppData\Local\anaconda3\envs\Assistants\Lib\site-packages\openai_base_client.py:889, in SyncAPIClient.request(self, cast_to, options, remaining_retries, stream, stream_cls) 880 def request( 881 self, 882 cast_to: Type[ResponseT], (...) 887 stream_cls: type[_StreamT] | None = None, 888 ) -> ResponseT | _StreamT: --> 889 return self._request( 890 cast_to=cast_to, 891 options=options, 892 stream=stream, 893 stream_cls=stream_cls, 894 remaining_retries=remaining_retries, 895 )

File c:\Users\testuser\AppData\Local\anaconda3\envs\Assistants\Lib\site-packages\openai_base_client.py:980, in SyncAPIClient._request(self, cast_to, options, remaining_retries, stream, stream_cls) 977 err.response.read() 979 log.debug("Re-raising status error") --> 980 raise self._make_status_error_from_response(err.response) from None 982 return self._process_response( 983 cast_to=cast_to, 984 options=options, (...) 987 stream_cls=stream_cls, 988 )

NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}

Expected behavior I expected no errors when creating an assistant and thread

Screenshots image

Please complete the following information:

Additional context I ran this code in VS Code

MarcoABCardoso commented 8 months ago

Hello @Kee2u !

It seems like the .env.example contains an API version not supported for the Assistants API. Could you test with the version 2024-02-15-preview and let us know if the issue is resolved?

In any case, we should update the .env.example file

@msalemor fyi

Kee2u commented 8 months ago

This worked for me. Thank you so much!