summaryrefslogtreecommitdiff
path: root/src/agentux/models.py
diff options
context:
space:
mode:
authorClaude Code <noreply@anthropic.com>2026-11-27 20:03:34 +0530
committerClaude Code <noreply@anthropic.com>2026-11-27 20:03:34 +0530
commited0a4782a21d8e564f8956c87e022e8caef851ac (patch)
treee65d6e0d0ddc23a1b1b9948a47a53245f0716e90 /src/agentux/models.py
parent95ea8c8b72d2dbb20ab860ab1505b46add280773 (diff)
Commit tracked-file changes required for a working Agentux installHEADmain
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.py27
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.