diff options
| author | Claude Code <noreply@anthropic.com> | 2026-11-27 20:03:34 +0530 |
|---|---|---|
| committer | Claude Code <noreply@anthropic.com> | 2026-11-27 20:03:34 +0530 |
| commit | ed0a4782a21d8e564f8956c87e022e8caef851ac (patch) | |
| tree | e65d6e0d0ddc23a1b1b9948a47a53245f0716e90 /src/agentux/models.py | |
| parent | 95ea8c8b72d2dbb20ab860ab1505b46add280773 (diff) | |
The committed provider/base.py, config.py, models.py, errors.py and tools
were missing symbols (e.g. TextCallback) that agent.py imports, so a clean
clone produced a broken install. Commit these so the remote's committed
state is complete and cloneable.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Diffstat (limited to 'src/agentux/models.py')
| -rw-r--r-- | src/agentux/models.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/agentux/models.py b/src/agentux/models.py index afb17cd..0dc42f1 100644 --- a/src/agentux/models.py +++ b/src/agentux/models.py @@ -55,6 +55,33 @@ class Message(BaseModel): payload["tool_call_id"] = self.tool_call_id return payload + @classmethod + def from_dict(cls, data: Dict[str, Any]) -> Message: + role = data.get("role", "user") + content = data.get("content") + tool_call_id = data.get("tool_call_id") + raw_calls = data.get("tool_calls") + parsed_calls = None + if raw_calls: + parsed_calls = [] + for c in raw_calls: + fn = c.get("function", {}) if isinstance(c.get("function"), dict) else {} + args = fn.get("arguments", {}) + if isinstance(args, str): + import json + try: + args = json.loads(args) + except Exception: + args = {} + parsed_calls.append( + ToolCall( + id=c.get("id", ""), + name=fn.get("name", c.get("name", "")), + arguments=args if isinstance(args, dict) else {}, + ) + ) + return cls(role=role, content=content, tool_calls=parsed_calls, tool_call_id=tool_call_id) + class ToolDefinition(BaseModel): """A tool advertised to the model. |
