Compare commits

...

1 Commits

5 changed files with 7 additions and 5 deletions

View File

@@ -345,7 +345,7 @@ def check_message_tokens(
if isinstance(message, AIMessage) and message.tool_calls:
for tool_call in message.tool_calls:
total_tokens += check_number_of_tokens(
json.dumps(tool_call["args"]), encode_fn
json.dumps(tool_call["args"], ensure_ascii=False), encode_fn
)
total_tokens += check_number_of_tokens(tool_call["name"], encode_fn)

View File

@@ -140,7 +140,7 @@ class CustomTool(BaseTool):
return json.dumps({"file_ids": image_response.file_ids})
# For JSON or other responses, return as-is
return json.dumps(response.tool_result)
return json.dumps(response.tool_result, ensure_ascii=False)
"""For LLMs which do NOT support explicit tool calling"""

View File

@@ -236,7 +236,8 @@ class ImageGenerationTool(Tool[None]):
"url": image_generation.url,
}
for image_generation in image_generations
]
],
ensure_ascii=False
),
)

View File

@@ -223,7 +223,7 @@ Return ONLY a valid JSON object with the extracted arguments. If no arguments ar
response=CustomToolCallSummary(
tool_name=self._name,
response_type="json",
tool_result=json.dumps({"tool_result": tool_result}),
tool_result=json.dumps({"tool_result": tool_result}, ensure_ascii=False),
),
)

View File

@@ -225,7 +225,8 @@ class SearchTool(Tool[SearchToolOverrideKwargs]):
llm_doc_to_dict(doc, ind)
for ind, doc in enumerate(final_context_docs)
]
}
},
ensure_ascii=False
)
"""For LLMs that don't support tool calling"""