Skip to content

Commit f4fe69e

Browse files
committed
Fix anthropic tool use
1 parent a3e9b5d commit f4fe69e

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

coverage-badge.svg

Lines changed: 1 addition & 1 deletion
Loading

synalinks/src/language_models/language_model.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,10 @@ async def __call__(self, messages, schema=None, streaming=False, **kwargs):
223223
)
224224
if streaming:
225225
return StreamingIterator(response)
226-
if self.model.startswith("groq") and schema:
226+
if (self.model.startswith("groq") or self.model.startswith("anthropic")) and schema:
227227
response_str = response["choices"][0]["message"]["tool_calls"][0][
228228
"function"
229229
]["arguments"]
230-
elif self.model.startswith("anthropic") and schema:
231-
for content_block in response["content"]:
232-
if content_block["type"] == "tool_use":
233-
response_str = json.dumps(content_block["input"])
234-
break
235230
else:
236231
response_str = response["choices"][0]["message"]["content"].strip()
237232
if schema:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)