mirror of
https://github.com/Hopiu/llm.git
synced 2026-05-20 11:31:52 +00:00
Response.add_tool_call() method and ToolCall class
Refs https://github.com/simonw/llm/issues/936#issuecomment-2869064678
This commit is contained in:
parent
84ab4cd409
commit
7b450c8215
1 changed files with 10 additions and 0 deletions
|
|
@ -177,6 +177,12 @@ class Tool:
|
|||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ToolCall:
|
||||
name: str
|
||||
arguments: dict
|
||||
|
||||
|
||||
@dataclass
|
||||
class Prompt:
|
||||
_prompt: Optional[str]
|
||||
|
|
@ -387,6 +393,7 @@ class _BaseResponse:
|
|||
self._key = key
|
||||
self._chunks: List[str] = []
|
||||
self._done = False
|
||||
self.tool_calls: List[ToolCall] = []
|
||||
self.response_json = None
|
||||
self.conversation = conversation
|
||||
self.attachments: List[Attachment] = []
|
||||
|
|
@ -404,6 +411,9 @@ class _BaseResponse:
|
|||
if self.prompt.tools and not self.model.supports_tools:
|
||||
raise ValueError(f"{self.model} does not support tools")
|
||||
|
||||
def add_tool_call(self, tool_call: ToolCall):
|
||||
self.tool_calls.append(tool_call)
|
||||
|
||||
def set_usage(
|
||||
self,
|
||||
*,
|
||||
|
|
|
|||
Loading…
Reference in a new issue