-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: mistral tool choice error #10821
Comments
Can you try updating to latest version of vLLM and see if you still get this error? |
|
How are you generating your tool call IDs? As stated by the error message, they should be alphanumeric and exactly 9 characters long. |
I looked at the tool ID and it's 6 digits of letters and numbers, is it possible that the new mistral's V3 has this length limitation, as running it on the original mistral-large-2407 didn't have this problem? |
@patrickvonplaten might have more context on this. |
getting the same issue when running "vllm serve mistralai/Pixtral-Large-Instruct-2411 --config-format mistral --load-format mistral --tokenizer_mode mistral --limit_mm_per_prompt 'image=10' --tensor-parallel-size 8" with all the latest versions of the library |
The mistral parser, when streaming, builds the tool_call_id in the following way:
This is not 9 alpha-numeric, which seems to be the template requirement. When returning with stream=False, the code is:
The later generates the 9 alphanumeric when init'ing the MistralToolCall using this method:
So the fix would seem to be to change the streaming code random generator to the same one used for stream=False. I have a PR #10782 that fixes other streaming issues with mistral and Hermes parsers. I can easily add this minor change to the PR. |
cc @K-Mistele |
I thought the tool ID length issue was fixed both in the streaming parser in a previous PR, and also in the chat template that we provided. If that's not the case though, then #10979 looks like a good answer. |
Your current environment
The output of `python collect_env.py`
Model Input Dumps
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/applications.py", line 113, in call
await self.middleware_stack(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 185, in call
with collapse_excgroups():
File "/model/anaconda3/envs/vllm/lib/python3.11/contextlib.py", line 158, in exit
self.gen.throw(typ, value, traceback)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
raise exc
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 187, in call
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/vllm/entrypoints/openai/api_server.py", line 490, in add_request_id
response = await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 163, in call_next
raise app_exc
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 185, in call
with collapse_excgroups():
File "/model/anaconda3/envs/vllm/lib/python3.11/contextlib.py", line 158, in exit
self.gen.throw(typ, value, traceback)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
raise exc
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 187, in call
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/vllm/entrypoints/openai/api_server.py", line 485, in authentication
return await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 163, in call_next
raise app_exc
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/base.py", line 149, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in call
await self.app(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/routing.py", line 715, in call
await self.middleware_stack(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/vllm/entrypoints/openai/api_server.py", line 347, in create_chat_completion
generator = await handler.create_chat_completion(request, raw_request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/vllm/entrypoints/openai/serving_chat.py", line 155, in create_chat_completion
) = await self._preprocess_chat(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/vllm/entrypoints/openai/serving_engine.py", line 458, in _preprocess_chat
request_prompt = apply_mistral_chat_template(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/vllm/entrypoints/chat_utils.py", line 767, in apply_mistral_chat_template
return tokenizer.apply_chat_template(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/vllm/transformers_utils/tokenizers/mistral.py", line 265, in apply_chat_template
encoded = self.mistral.encode_chat_completion(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/mistral_common/tokens/tokenizers/mistral.py", line 194, in encode_chat_completion
validated_request = self._chat_completion_request_validator.validate_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/mistral_common/protocol/instruct/validator.py", line 63, in validate_request
self.validate_messages(request.messages)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/mistral_common/protocol/instruct/validator.py", line 51, in validate_messages
self._validate_message_list_content(messages)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/mistral_common/protocol/instruct/validator.py", line 273, in _validate_message_list_content
self._validate_assistant_message(message, is_last_message=idx == len(messages) - 1)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/mistral_common/protocol/instruct/validator.py", line 155, in _validate_assistant_message
self._validate_tool_call(tool_call, is_last_message=is_last_message)
File "/model/anaconda3/envs/vllm/lib/python3.11/site-packages/mistral_common/protocol/instruct/validator.py", line 310, in _validate_tool_call
raise InvalidFunctionCallException(
mistral_common.exceptions.InvalidFunctionCallException: Tool call id was m0bqB5RX6Xqr but must be a-z, A-Z, 0-9, with a length of 9.
🐛 Describe the bug
vllm serve /model/models/Pixtral-Large-Instruct-2411 -tp 1 --served-model-name Pixtral-Large-Instruct-2411 --dtype float16 --gpu-memory-utilization 0.925 --max-model-len 16384 --max-num-seqs 16 --tokenizer_mode mistral --enable-auto-tool-choice --tool-call-parser mistral --chat-template /vllm/examples/tool_chat_template_mistral_parallel.jinja
mistral_common==1.5.0
Before submitting a new issue...
The text was updated successfully, but these errors were encountered: