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
6.15k stars 4.18k forks source link

Azure Document Intelligence failed. ---Bad Request #1097

Open toby080508050805 opened 10 months ago

toby080508050805 commented 10 months 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

Follow the document to run azd up

Any log messages given by the failure

Splitting 'test4.pdf' into sections Uploading blob for whole file -> test4.pdf Traceback (most recent call last): File "/workspaces/azure-search-openai-demo/./scripts/prepdocs.py", line 310, in loop.run_until_complete(main(file_strategy, azd_credential, args)) File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/./scripts/prepdocs.py", line 160, in main await strategy.run(search_info) File "/workspaces/azure-search-openai-demo/scripts/prepdocslib/filestrategy.py", line 76, in run await search_manager.update_content(sections, blob_image_embeddings) File "/workspaces/azure-search-openai-demo/scripts/prepdocslib/searchmanager.py", line 170, in update_content embeddings = await self.embeddings.create_embeddings( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/scripts/prepdocslib/embeddings.py", line 118, in create_embeddings return await self.create_embedding_batch(texts) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/scripts/prepdocslib/embeddings.py", line 89, in create_embedding_batch async for attempt in AsyncRetrying( File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.11/site-packages/tenacity/_asyncio.py", line 71, in anext do = self.iter(retry_state=self._retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.11/site-packages/tenacity/init.py", line 314, in iter return fut.result() ^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 449, in result return self.get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in get_result raise self._exception File "/workspaces/azure-search-openai-demo/scripts/prepdocslib/embeddings.py", line 96, in create_embedding_batch emb_response = await client.embeddings.create(model=self.open_ai_model_name, input=batch.texts) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.11/site-packages/openai/resources/embeddings.py", line 198, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 1542, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 1316, in request return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 1368, in _request raise self._make_status_error_from_response(err.response) from None openai.BadRequestError:

Bad Request

Bad Request

Error parsing headers: 'limit request headers fields size'

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Linux cc45c391c6c7 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 GNU/Linux

azd version?

run azd version and copy paste here.

azd version 1.5.1 (commit 3856d1e98281683b8d112e222c0a7c7b3e148e96)

Mention any other details that might be useful


Thanks! We'll be in touch soon.

mattgotteiner commented 10 months ago

Thanks for reporting this - we'll investigate.

In the meantime - can you try using key-based authentication? If you add --formrecognizerkey YOUR_DOCUMENT_INTELLIGENCE_KEY to the prepdocs command line, let us know if that works

mattgotteiner commented 10 months ago

Hi @toby080508050805 ,

can you please let us know

  1. Are you using OpenAI embeddings, or Azure OpenAI embeddings?
  2. Did you customize your data or use the existing sample data
toby080508050805 commented 10 months ago

Hi Matt,

Thanks for your reply.

1.If you add --formrecognizerkey YOUR_DOCUMENT_INTELLIGENCE_KEY to the prepdocs command line, let us know if that works <== May I know how to do it ??

  1. I followed the instruction from readme.md to create the docker and did not change anything.

Start Docker Desktop (install it if not already installed) Open the project: Open in Dev Containers In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window Run azd auth login Now you can follow the instructions in Deploying from scratch below

3.I apply the sample data have the issue so I create my own test data which only have few lines to test.

toby080508050805 commented 10 months ago

I add the parameter you mention at very end of prepdocs.sh but it still not work. --formrecognizerkey "e55d4b6b1**9d9b3" \

mattgotteiner commented 10 months ago

Hi @toby080508050805 ,

can you please let us know

Are you using OpenAI embeddings, or Azure OpenAI embeddings? Did you customize your data or use the existing sample data