Unverified Commit a32783bb authored by Chauncey's avatar Chauncey Committed by GitHub
Browse files

[Bugfix] Fix IndexError when accessing prev_tool_call_arr in OpenAIToolParser (#37958)


Signed-off-by: default avatarchaunceyjiang <chaunceyjiang@gmail.com>
parent 9d0351c9
...@@ -1089,6 +1089,7 @@ class OpenAIServingChat(OpenAIServing): ...@@ -1089,6 +1089,7 @@ class OpenAIServingChat(OpenAIServing):
# any tokens that were generated but previously # any tokens that were generated but previously
# matched by partial json parsing # matched by partial json parsing
# only happens if we are NOT using structured outputs # only happens if we are NOT using structured outputs
index = 0
auto_tools_called = False auto_tools_called = False
if tool_parser: if tool_parser:
auto_tools_called = len(tool_parser.prev_tool_call_arr) > 0 auto_tools_called = len(tool_parser.prev_tool_call_arr) > 0
...@@ -1097,15 +1098,14 @@ class OpenAIServingChat(OpenAIServing): ...@@ -1097,15 +1098,14 @@ class OpenAIServingChat(OpenAIServing):
if auto_tools_called if auto_tools_called
else 0 else 0
) )
else: should_check = (
index = 0
if (
self._should_check_for_unstreamed_tool_arg_tokens( self._should_check_for_unstreamed_tool_arg_tokens(
delta_message, output delta_message, output
) )
and tool_parser )
): # only check if there are any tool calls
# detected by partial parsing
if should_check and tool_parser and auto_tools_called:
latest_delta_len = 0 latest_delta_len = 0
if ( if (
isinstance( isinstance(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment