upgrade run ui

This commit is contained in:
Shivering Ocelot committed 2026-06-06 16:36:01 -05:00
1 parent bb204f2c6c
commit a10224d21e
6 files changed
+91 -18

No files matched your search

+27 -3
View File
@@ -115,6 +115,30 @@ class ToolSpec:
def __repr__(self):
return f"ToolSpec(name={self.name!r}, params={[p.name for p in self.parameters]})"
class Tool:
"""Base class for tools that implement their logic in a 'run' method.
Subclasses should override 'run' to provide the tool's functionality.
"""
def __init__(self):
pass
def run(self, **kwargs):
"""Execute the tool. To be overridden by subclasses."""
raise NotImplementedError("Tool subclasses must override the 'run' method.")
def to_spec(self):
"""Generate a ToolSpec from this tool instance."""
return ToolSpec(
name=None, # TODO: Computed from class name, or from class attribute
description=None, # TODO: From class doc comment
parameters=None, # TODO: Class attribute
func=self.run,
)
def __repr__(self):
return f"Tool(name={self.name!r}, params={[p.name for p in self.parameters]})"
class ToolCall:
"""Represents a single tool invocation request emitted by the model.
@@ -123,7 +147,7 @@ class ToolCall:
id: Unique call identifier (used by OpenAI / llama-cpp protocol).
tool_name: Name of the tool to invoke.
arguments: Dict of argument name → value.
result: String content returned by the tool.
result: String content returned by the tool.
is_error: Whether the result represents an error.
"""
@@ -136,10 +160,10 @@ class ToolCall:
def __repr__(self):
return f"ToolCall(tool={self.tool_name!r}, args={self.arguments!r})"
def call_message(self):
raise Exception("TODO: Llama message for tool call")
def result_message(self):
from inference import LlamaMessage
return LlamaMessage("tool", self.result)