Unverified Commit beb16b2c authored by Travis Johnson's avatar Travis Johnson Committed by GitHub
Browse files

[Bugfix] Handle <|tool_call|> token in granite tool parser (#11039)


Signed-off-by: default avatarTravis Johnson <tsjohnso@us.ibm.com>
parent fe2e10c7
......@@ -35,11 +35,13 @@ class GraniteToolParser(ToolParser):
def __init__(self, tokenizer: AnyTokenizer):
super().__init__(tokenizer)
self.bot_token = "<|tool_call|>"
def extract_tool_calls(
self, model_output: str,
request: ChatCompletionRequest) -> ExtractedToolCallInformation:
stripped = model_output.strip()
# remove whitespace and the BOT token if it exists
stripped = model_output.strip().removeprefix(self.bot_token).lstrip()
if not stripped or stripped[0] != '[':
return ExtractedToolCallInformation(tools_called=False,
tool_calls=[],
......
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