Skip to content

Commit 619cb3a

Browse files
committed
improve agent code
1 parent 38a3d3a commit 619cb3a

File tree

7 files changed

+470
-78
lines changed

7 files changed

+470
-78
lines changed

examples/agent_layers_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def demo_layer2_sentience_agent():
8585
print(" Code required: ~10 lines")
8686
print(" Technical knowledge: Medium")
8787
print(" Flexibility: High")
88-
print(f" Tokens used: {agent.get_token_stats()['total_tokens']}")
88+
# Use new TokenStats dataclass
89+
stats = agent.get_token_stats()
90+
print(f" Tokens used: {stats.total_tokens}")
8991

9092

9193
def demo_layer3_conversational_agent():

sentience/__init__.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@
33
"""
44

55
from .browser import SentienceBrowser
6-
from .models import Snapshot, Element, BBox, Viewport, ActionResult, WaitResult
6+
from .models import (
7+
Snapshot,
8+
Element,
9+
BBox,
10+
Viewport,
11+
ActionResult,
12+
WaitResult,
13+
# Agent Layer Models
14+
AgentActionResult,
15+
TokenStats,
16+
ActionHistory,
17+
ActionTokenUsage,
18+
SnapshotOptions,
19+
SnapshotFilter,
20+
ScreenshotConfig
21+
)
722
from .snapshot import snapshot
823
from .query import query, find
924
from .actions import click, type_text, press, click_rect
@@ -16,6 +31,7 @@
1631
from .screenshot import screenshot
1732

1833
# Agent Layer (Phase 1 & 2)
34+
from .base_agent import BaseAgent
1935
from .llm_provider import LLMProvider, LLMResponse, OpenAIProvider, AnthropicProvider, LocalLLMProvider
2036
from .agent import SentienceAgent
2137
from .conversational_agent import ConversationalAgent
@@ -51,12 +67,21 @@
5167
"read",
5268
"screenshot",
5369
# Agent Layer (Phase 1 & 2)
70+
"BaseAgent",
5471
"LLMProvider",
5572
"LLMResponse",
5673
"OpenAIProvider",
5774
"AnthropicProvider",
5875
"LocalLLMProvider",
5976
"SentienceAgent",
6077
"ConversationalAgent",
78+
# Agent Layer Models
79+
"AgentActionResult",
80+
"TokenStats",
81+
"ActionHistory",
82+
"ActionTokenUsage",
83+
"SnapshotOptions",
84+
"SnapshotFilter",
85+
"ScreenshotConfig",
6186
]
6287

0 commit comments

Comments
 (0)