Skip to content

Commit 7b341e4

Browse files
committed
fix: enhance tool-call handling and tokenization in OpenAICompatibleTinkerServer
- Updated regex to correctly match tool-call tags, allowing for optional leading newline. - Ensured content is set to None if no message content is present. - Added byte encoding for tokens during tokenization for improved processing.
1 parent afbf863 commit 7b341e4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/art/tinker/server.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,15 @@ async def chat_completions(
134134
# from the content, so we remove them here.
135135
content=(
136136
re.sub(
137-
r"(?:\n<tool_call>.*?</tool_call>)+\s*$",
137+
r"(?:\n?<tool_call>.*?</tool_call>)+\s*$",
138138
"",
139139
message["content"],
140140
flags=re.DOTALL,
141141
)
142142
if message["content"]
143143
else message["content"]
144-
),
144+
)
145+
or None,
145146
role="assistant",
146147
tool_calls=[
147148
ChatCompletionMessageFunctionToolCall(
@@ -160,6 +161,9 @@ async def chat_completions(
160161
content=[
161162
ChatCompletionTokenLogprob(
162163
token=f"token_id:{token}",
164+
bytes=list(
165+
renderer.tokenizer.decode(token).encode()
166+
),
163167
logprob=logprob,
164168
top_logprobs=[],
165169
)

0 commit comments

Comments
 (0)