A large PDF document can't be indexed with Azure OpenAI Serive becuase of openai.RateLimitError #2581

Closed
opened 2026-02-21 17:47:32 -05:00 by yindo · 0 comments
Owner

Originally created by @masatatsu8 on GitHub (Apr 24, 2024).

Originally assigned to: @JohnJyong on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a quesion, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.64

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I uploaded a PDF file (size: 3.5MB) in the knowledge section

  • using ETL by unstructured.io
  • use 'text-embedding-ada-002' provided by Azure OpenAI Service (Japan East, S0)

✔️ Expected Behavior

Indexing should be finished successfully even if the limited rate of API call for embedding is granted. (Currently we have a rate of 130k Token Per Minutes which is the default setting, I believe)

Actual Behavior

The status of indexing was "Error".

Here is a port of DEBUG log of API backend server:

[2024-04-25 01:48:31,946: ERROR/MainProcess] consume document failed
Traceback (most recent call last):
  File "/app/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 31, in invoke
    return self._invoke(model, credentials, texts, user)
  File "/app/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py", line 58, in _invoke
    embeddings_batch, embedding_used_tokens = self._embedding_invoke(
  File "/app/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py", line 153, in _embedding_invoke
    response = client.embeddings.create(
  File "/usr/local/lib/python3.10/site-packages/openai/resources/embeddings.py", line 113, in create
    return self._post(
  File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 1208, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
  File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 897, in request
    return self._request(
  File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 973, in _request
    return self._retry_request(
  File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 1021, in _retry_request
    return self._request(
  File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 988, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.RateLimitError: Error code: 429 - {'error': {'code': '429', 'message': 'Requests to the Embeddings_Create Operation under Azure OpenAI API version 2024-02-15-preview have exceeded call rate limit of your current OpenAI S0 pricing tier. Please retry after 1 second. Please go here: https://aka.ms/oai/quotaincrease if you would like to further increase the default rate limit.'}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/api/core/indexing_runner.py", line 73, in run
    self._load(
  File "/app/api/core/indexing_runner.py", line 677, in _load
    tokens += future.result()
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/api/core/indexing_runner.py", line 732, in _process_chunk
    index_processor.load(dataset, chunk_documents, with_keywords=False)
  File "/app/api/core/rag/index_processor/processor/paragraph_index_processor.py", line 60, in load
    vector.create(documents)
  File "/app/api/core/rag/datasource/vdb/vector_factory.py", line 146, in create
    embeddings = self._embeddings.embed_documents([document.page_content for document in texts])
  File "/app/api/core/embedding/cached_embedding.py", line 82, in embed_documents
    raise ex
  File "/app/api/core/embedding/cached_embedding.py", line 51, in embed_documents
    embedding_result = self._model_instance.invoke_text_embedding(
  File "/app/api/core/model_manager.py", line 95, in invoke_text_embedding
    return self.model_type_instance.invoke(
  File "/app/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 33, in invoke
    raise self._transform_invoke_error(e)
core.model_runtime.errors.invoke.InvokeRateLimitError: [azure_openai] Rate Limit Error, Error code: 429 - {'error': {'code': '429', 'message': 'Requests to the Embeddings_Create Operation under Azure OpenAI API version 2024-02-15-preview have exceeded call rate limit of your current OpenAI S0 pricing tier. Please retry after 1 second. Please go here: https://aka.ms/oai/quotaincrease if you would like to further increase the default rate limit.'}}
[2024-04-25 01:48:31,980: INFO/MainProcess] Processed dataset: 3dd0c8cc-e8f4-4737-bb75-b2c7a28e91d6 latency: 292.7815747699933
Originally created by @masatatsu8 on GitHub (Apr 24, 2024). Originally assigned to: @JohnJyong on GitHub. ### Self Checks - [X] This is only for bug report, if you would like to ask a quesion, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Dify version 0.64 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I uploaded a PDF file (size: 3.5MB) in the knowledge section - using ETL by unstructured.io - use 'text-embedding-ada-002' provided by Azure OpenAI Service (Japan East, S0) ### ✔️ Expected Behavior Indexing should be finished successfully even if the limited rate of API call for embedding is granted. (Currently we have a rate of 130k Token Per Minutes which is the default setting, I believe) ### ❌ Actual Behavior The status of indexing was "Error". Here is a port of DEBUG log of API backend server: ```text [2024-04-25 01:48:31,946: ERROR/MainProcess] consume document failed Traceback (most recent call last): File "/app/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 31, in invoke return self._invoke(model, credentials, texts, user) File "/app/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py", line 58, in _invoke embeddings_batch, embedding_used_tokens = self._embedding_invoke( File "/app/api/core/model_runtime/model_providers/azure_openai/text_embedding/text_embedding.py", line 153, in _embedding_invoke response = client.embeddings.create( File "/usr/local/lib/python3.10/site-packages/openai/resources/embeddings.py", line 113, in create return self._post( File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 1208, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 897, in request return self._request( File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 973, in _request return self._retry_request( File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 1021, in _retry_request return self._request( File "/usr/local/lib/python3.10/site-packages/openai/_base_client.py", line 988, in _request raise self._make_status_error_from_response(err.response) from None openai.RateLimitError: Error code: 429 - {'error': {'code': '429', 'message': 'Requests to the Embeddings_Create Operation under Azure OpenAI API version 2024-02-15-preview have exceeded call rate limit of your current OpenAI S0 pricing tier. Please retry after 1 second. Please go here: https://aka.ms/oai/quotaincrease if you would like to further increase the default rate limit.'}} During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/api/core/indexing_runner.py", line 73, in run self._load( File "/app/api/core/indexing_runner.py", line 677, in _load tokens += future.result() File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 451, in result return self.__get_result() File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result raise self._exception File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/app/api/core/indexing_runner.py", line 732, in _process_chunk index_processor.load(dataset, chunk_documents, with_keywords=False) File "/app/api/core/rag/index_processor/processor/paragraph_index_processor.py", line 60, in load vector.create(documents) File "/app/api/core/rag/datasource/vdb/vector_factory.py", line 146, in create embeddings = self._embeddings.embed_documents([document.page_content for document in texts]) File "/app/api/core/embedding/cached_embedding.py", line 82, in embed_documents raise ex File "/app/api/core/embedding/cached_embedding.py", line 51, in embed_documents embedding_result = self._model_instance.invoke_text_embedding( File "/app/api/core/model_manager.py", line 95, in invoke_text_embedding return self.model_type_instance.invoke( File "/app/api/core/model_runtime/model_providers/__base/text_embedding_model.py", line 33, in invoke raise self._transform_invoke_error(e) core.model_runtime.errors.invoke.InvokeRateLimitError: [azure_openai] Rate Limit Error, Error code: 429 - {'error': {'code': '429', 'message': 'Requests to the Embeddings_Create Operation under Azure OpenAI API version 2024-02-15-preview have exceeded call rate limit of your current OpenAI S0 pricing tier. Please retry after 1 second. Please go here: https://aka.ms/oai/quotaincrease if you would like to further increase the default rate limit.'}} [2024-04-25 01:48:31,980: INFO/MainProcess] Processed dataset: 3dd0c8cc-e8f4-4737-bb75-b2c7a28e91d6 latency: 292.7815747699933 ```
yindo closed this issue 2026-02-21 17:47:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#2581