Azure-Samples / azure-search-openai-demo

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
https://azure.microsoft.com/products/search
MIT License
5.94k stars 4.08k forks source link

Operation returned an invalid status 'Unauthorized' #276

Open mca-d opened 1 year ago

mca-d commented 1 year ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Running the app locally

  1. Run azd login
  2. Change dir to app
  3. Run ./start.sh

I am using keys so I commented out the token mentions and set the keys as env variables

Any log messages given by the failure

azure.core.exceptions.ClientAuthenticationError: Operation returned an invalid status 'Unauthorized'

Expected/desired behavior

Being able to get a response when running the demo code

OS and Version?

macOS Ventura

azd version?

azd version 1.0.1 (commit e0cd1aca716fa5d08704beade7dcc734fe68f5f1)

Versions

Mention any other details that might be useful

I am using the documents provided by the demo.


Thanks! We'll be in touch soon.

jongio commented 1 year ago

Did you run azd up?

mca-d commented 1 year ago

I am running it locally, not deploying it. If I run azd up I get the error that I don't have 'roleAssignments/write' (which is true) After doing some digging i see that the error is coming from chatreadretrieveread.py, it completes step 1, but it fails when calling search_client...

apvarana commented 1 year ago

I am getting same issue while running locally, did u find a resolution

mca-d commented 1 year ago

I am getting same issue while running locally, did u find a resolution

No :(

ZepposBE commented 1 year ago

Getting this also while running locally:

Error: Operation returned an invalid status 'Unauthorized'

Also, same as @mca-d

ERROR:root:Exception in /ask Traceback (most recent call last): File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\app.py", line 96, in ask r = impl.run(request.json["question"], request.json.get("overrides") or {}) File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\approaches\retrievethenread.py", line 68, in run results = [doc[self.sourcepage_field] + ": " + nonewlines(doc[self.content_field]) for doc in r] File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\approaches\retrievethenread.py", line 68, in <listcomp> results = [doc[self.sourcepage_field] + ": " + nonewlines(doc[self.content_field]) for doc in r] File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\backend_env\lib\site-packages\azure\search\documents\_paging.py", line 54, in __next__ return next(self._page_iterator) File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\backend_env\lib\site-packages\azure\core\paging.py", line 76, in __next__ self._response = self._get_next(self.continuation_token) File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\backend_env\lib\site-packages\azure\search\documents\_paging.py", line 114, in _get_next_cb return self._client.documents.search_post( File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\backend_env\lib\site-packages\azure\core\tracing\decorator.py", line 76, in wrapper_use_tracer return func(*args, **kwargs) File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\backend_env\lib\site-packages\azure\search\documents\_generated\operations\_documents_operations.py", line 780, in search_post map_error(status_code=response.status_code, response=response, error_map=error_map) File "C:\Projects\Azure Search OpenAI Demo\azure-search-openai-demo\app\backend\backend_env\lib\site-packages\azure\core\exceptions.py", line 109, in map_error raise error azure.core.exceptions.ClientAuthenticationError: Operation returned an invalid status 'Unauthorized'

marceloricciardi commented 1 year ago

Same issue here too.

marceloricciardi commented 1 year ago

Same issue here too.

This solved my problem: https://github.com/Azure-Samples/azure-search-openai-demo/issues/17#issuecomment-1472074150

Aravind03 commented 1 year ago

Hi All,

In my case, my Architect have deployed the solution and I tried to integrate that with a different new Search Service(Free tier) created manually within the same subscription and received the same error.

When compared the settings, it was identified that the below configuration is the problem. Please check once in your environment.

In the Search service, select Keys under Settings in the left navigation. Now select Both radio button under 'API access control'

rafajot1 commented 12 months ago

In my case (not openai but I think this is irrelevant) this was a system clock issue (typical for WSL that it gous out of sync)

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this issue will be closed.