Skip to content

Commit 9a93406

Browse files
committed
Small fix for ollama truncation check. Small fix for pythonic tool repr rendering.
1 parent e9c4c43 commit 9a93406

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "rigging"
3-
version = "3.3.4"
3+
version = "3.3.5"
44
description = "LLM Interaction Framework"
55
authors = ["Nick Landers <monoxgas@gmail.com>"]
66
license = "MIT"

rigging/generator/litellm_.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,17 @@ def _warn_on_input_truncation(
254254
# - https://github.com/ollama/ollama/issues/7987
255255
# - https://github.com/ollama/ollama/issues/4967
256256

257+
# Not perfect
258+
if "ollama" not in self.model.lower():
259+
return
260+
257261
# We can't check with usage info
258262
if not response.usage:
259263
return
260264

261265
# Get a general view of how long we might expect the input prompt to
262-
# We'll use a gracious 4 char per token estimate
263-
input_tokens_estimate = int(sum(len(message.content) for message in messages) / 4)
266+
# We'll use a gracious 10 char per token estimate
267+
input_tokens_estimate = int(sum(len(message.content) for message in messages) / 10)
264268

265269
# Check if the response reports that accepted input tokens are less than this
266270
if response.usage.input_tokens < input_tokens_estimate:

rigging/transform/pythonic_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _attempt_parse_tool_calls_from_string(candidate_str: str) -> list[ToolCall]
104104
def _render_tool_call_to_pythonic_string(tool_call: ToolCall) -> str:
105105
"""Renders a single ToolCall object to its pythonic string representation."""
106106
args_dict = json.loads(tool_call.function.arguments)
107-
args_str = ", ".join(f"{key}={json.dumps(value)}" for key, value in args_dict.items())
107+
args_str = ", ".join(f"{key}={value!r}" for key, value in args_dict.items())
108108
return f"{tool_call.function.name}({args_str})"
109109

110110

0 commit comments

Comments
 (0)