zylon-ai / private-gpt

Interact with your documents using the power of GPT, 100% privately, no data leaks

Home Page:https://privategpt.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openai 400 bad request

Oooooooooooooooooooooooooooops opened this issue · comments

13:50:40.848 [INFO ] httpx - HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 400 Bad Request" 13:50:40.849 [WARNING ] llama_index.embeddings.openai.utils - Retrying llama_index.embeddings.openai.base.get_embeddings in 0.32954051740667456 seconds as it raised BadRequestError: Error code: 400 - {'error': {'message': "This model's maximum context length is 8192 tokens, however you requested 10738 tokens (10738 in your prompt; 0 for the completion). Please reduce your prompt; or completion length.", 'type': 'invalid_request_error', 'param': None, 'code': None}}. 13:50:42.219 [INFO ] httpx - HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 400 Bad Request" 13:50:42.220 [WARNING ] llama_index.embeddings.openai.utils - Retrying llama_index.embeddings.openai.base.get_embeddings in 1.7099388852871833 seconds as it raised BadRequestError: Error code: 400 - {'error': {'message': "This model's maximum context length is 8192 tokens, however you requested 10738 tokens (10738 in your prompt; 0 for the completion). Please reduce your prompt; or completion length.", 'type': 'invalid_request_error', 'param': None, 'code': None}}. 13:50:45.326 [INFO ] httpx - HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 400 Bad Request" 13:50:45.328 [WARNING ] llama_index.embeddings.openai.utils - Retrying llama_index.embeddings.openai.base.get_embeddings in 1.5669134759497618 seconds as it raised BadRequestError: Error code: 400 - {'error': {'message': "This model's maximum context length is 8192 tokens, however you requested 10738 tokens (10738 in your prompt; 0 for the completion). Please reduce your prompt; or completion length.", 'type': 'invalid_request_error', 'param': None, 'code': None}}. 13:50:47.974 [INFO ] httpx - HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 400 Bad Request" 13:50:47.975 [WARNING ] llama_index.embeddings.openai.utils - Retrying llama_index.embeddings.openai.base.get_embeddings in 1.1000125861106085 seconds as it raised BadRequestError: Error code: 400 - {'error': {'message': "This model's maximum context length is 8192 tokens, however you requested 10738 tokens (10738 in your prompt; 0 for the completion). Please reduce your prompt; or completion length.", 'type': 'invalid_request_error', 'param': None, 'code': None}}. 13:50:49.665 [INFO ] httpx - HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 400 Bad Request" 13:50:49.666 [WARNING ] llama_index.embeddings.openai.utils - Retrying llama_index.embeddings.openai.base.get_embeddings in 12.676405614673598 seconds as it raised BadRequestError: Error code: 400 - {'error': {'message': "This model's maximum context length is 8192 tokens, however you requested 10738 tokens (10738 in your prompt; 0 for the completion). Please reduce your prompt; or completion length.", 'type': 'invalid_request_error', 'param': None, 'code': None}}. 13:51:03.310 [INFO ] httpx - HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 400 Bad Request" Traceback (most recent call last): File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/gradio/queueing.py", line 527, in process_events response = await route_utils.call_process_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/gradio/route_utils.py", line 261, in call_process_api output = await app.get_blocks().process_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/gradio/blocks.py", line 1786, in process_api result = await self.call_function( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/gradio/blocks.py", line 1338, in call_function prediction = await anyio.to_thread.run_sync( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/anyio/to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/gradio/utils.py", line 759, in wrapper response = f(*args, **kwargs) ^^^^^^^^^^^^^^^^^^ File "/root/private-gpt/private_gpt/ui/ui.py", line 253, in _upload_file self._ingest_service.bulk_ingest([(str(path.name), path) for path in paths]) File "/root/private-gpt/private_gpt/server/ingest/ingest_service.py", line 87, in bulk_ingest documents = self.ingest_component.bulk_ingest(files) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/private-gpt/private_gpt/components/ingest/ingest_component.py", line 135, in bulk_ingest saved_documents.extend(self._save_docs(documents)) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/private-gpt/private_gpt/components/ingest/ingest_component.py", line 142, in _save_docs self._index.insert(document, show_progress=True) File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/llama_index/core/indices/base.py", line 225, in insert nodes = run_transformations( ^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/llama_index/core/ingestion/pipeline.py", line 127, in run_transformations nodes = transform(nodes, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/llama_index/core/base/embeddings/base.py", line 334, in __call__ embeddings = self.get_text_embedding_batch( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/llama_index/core/base/embeddings/base.py", line 255, in get_text_embedding_batch embeddings = self._get_text_embeddings(cur_batch) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/llama_index/embeddings/openai/base.py", line 419, in _get_text_embeddings return get_embeddings( ^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 289, in wrapped_f return self(f, *args, **kw) ^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 379, in __call__ do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 325, in iter raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 158, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 382, in __call__ result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/llama_index/embeddings/openai/base.py", line 180, in get_embeddings data = client.embeddings.create(input=list_of_text, model=engine, **kwargs).data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/openai/resources/embeddings.py", line 106, in create return self._post( ^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/openai/_base_client.py", line 1088, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/openai/_base_client.py", line 853, in request return self._request( ^^^^^^^^^^^^^^ File "/root/.cache/pypoetry/virtualenvs/private-gpt-mY4xTVOV-py3.11/lib/python3.11/site-packages/openai/_base_client.py", line 930, in _request raise self._make_status_error_from_response(err.response) from None

I'm also contributing to open-source and I immediately close such issues, I believe we should close issue like that.

@Oooooooooooooooooooooooooooops Do you really imagine that the author of private-gpt will even have a look at it? Seriously?

There's nothing relevant in there, no structure, no hello, no thanks, no context, no nothing than just a blog of text log blob.

I'm also contributing to open-source and I immediately close such issues, I believe we should close issue like that.

@Oooooooooooooooooooooooooooops Do you really imagine that the author of private-gpt will even have a look at it? Seriously?

There's nothing relevant in there, no structure, no hello, no thanks, no context, no nothing than just a blog of text log blob.

You're a toxic.
I have only provided the information I received, nothing extra. And yes, I am grateful to the author for such a product, as well as all those who identify errors.

Keep calm guys :)
Talking of the original post, if you read the server response error, you'll know that you've tried to send more tokens than your model supports by throwing a 400 response. Please check if there are any sentences that are too long, or switch to a fixed chunk strategy to fix it.