vllm icon indicating copy to clipboard operation
vllm copied to clipboard

[Bug]: 400 Bad Request

Open gaye746560359 opened this issue 9 months ago • 3 comments

Your current environment

使用docker run --gpus all -v D:\docker\huggingface:/root/.cache/huggingface --env "HUGGING_FACE_HUB_TOKEN=****************" -d -p 8000:8000 --ipc=host --name vllm vllm/vllm-openai:latest --model nvidia/Llama3-ChatQA-1.5-8B --api-key vllm-abc123456 --gpu-memory-utilization 0.9部署成功了server端

客户端运行下面的代码报错: from openai import OpenAI

Set OpenAI's API key and API base to use vLLM's API server.

openai_api_key = "vllm-abc123456" openai_api_base = "http://192.168.2.6:8000/v1"

client = OpenAI( api_key=openai_api_key, base_url=openai_api_base, )

chat_response = client.chat.completions.create( model="nvidia/Llama3-ChatQA-1.5-8B", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Tell me a joke."}, ], extra_body = { "guided_choice": ["positive", "negative"] } ).choices[0].message.content print("Chat response:", chat_response)

错误: D:\docker\vllm\venv\Scripts\python.exe D:\docker\vllm\llm_client.py Traceback (most recent call last): File "D:\docker\vllm\llm_client.py", line 14, in chat_response = client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_utils_utils.py", line 277, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai\resources\chat\completions.py", line 579, in create return self._post( ^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1240, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 921, in request return self._request( ^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1020, in _request raise self._make_status_error_from_response(err.response) from None openai.BadRequestError: 400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

🐛 Describe the bug

D:\docker\vllm\venv\Scripts\python.exe D:\docker\vllm\llm_client.py Traceback (most recent call last): File "D:\docker\vllm\llm_client.py", line 14, in chat_response = client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_utils_utils.py", line 277, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai\resources\chat\completions.py", line 579, in create return self._post( ^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1240, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 921, in request return self._request( ^^^^^^^^^^^^^^ File "D:\docker\vllm\venv\Lib\site-packages\openai_base_client.py", line 1020, in _request raise self._make_status_error_from_response(err.response) from None openai.BadRequestError: 400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

gaye746560359 avatar May 04 '24 14:05 gaye746560359

Have you tried using HTTPS instead of HTTP according to the error message?

- openai_api_base = "http://192.168.2.6:8000/v1"
+ openai_api_base = "https://192.168.2.6:8000/v1"

DarkLight1337 avatar May 05 '24 06:05 DarkLight1337

Have you tried using HTTPS instead of HTTP according to the error message?


- openai_api_base = "http://192.168.2.6:8000/v1"

+ openai_api_base = "https://192.168.2.6:8000/v1"

我是本地部署的,没有https只有http

gaye746560359 avatar May 05 '24 08:05 gaye746560359

I'm seeing a 400 bad request with 0.4.2 (vllm.entrypoints.openai.api_server) that does not occur with 0.4.1 with nothing else changing.... It's strange because if I submit my normal test CURL request, it works fine, but my application using axios returns the 400... Reverting to 0.4.1 and everything works. This has to be a regression.

freespeech4ever avatar May 06 '24 06:05 freespeech4ever

The issue I mentioned above still occurs with the latest, 0.5.0-post1. I'm stuck on 0.4.1 to have a functioning openai api server.

freespeech4ever avatar Jun 22 '24 05:06 freespeech4ever

I'm seeing a 400 bad request with 0.4.2 (vllm.entrypoints.openai.api_server) that does not occur with 0.4.1 with nothing else changing.... It's strange because if I submit my normal test CURL request, it works fine, but my application using axios returns the 400... Reverting to 0.4.1 and everything works. This has to be a regression.

I encountered this issue as well. I think it's caused by the current default output being set to streaming. As long as you set 'stream': false, you should be able to get the correct response.

dongxiaolong avatar Aug 15 '24 05:08 dongxiaolong

In my case, it was items in the messages array containing extra fields... date, and _id... This is the core of the breaking change that occurred after 0.4.1. The API is extremely rigid now in validating the input. I've worked around it in my app by stripping out the fields before submission, but not excited about that.

freespeech4ever avatar Aug 18 '24 15:08 freespeech4ever

same error , please fix

lwdnxu avatar Sep 04 '24 09:09 lwdnxu

In my case, it was items in the messages array containing extra fields... date, and _id... This is the core of the breaking change that occurred after 0.4.1. The API is extremely rigid now in validating the input. I've worked around it in my app by stripping out the fields before submission, but not excited about that.

This was an intentional change in response to #4339. Sorry for the late reply!

same error , please fix

Please provide more information about this.

DarkLight1337 avatar Sep 04 '24 09:09 DarkLight1337