Skip to content

Commit ebccd24

Browse files
committed
some minor adjustments
1 parent 68b133c commit ebccd24

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

run_ui.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
poetry run python src/agentwatch/cli.py ui
2+
AGENTWATCH_INTERNAL=1 PYTHONPATH=$PYTHONPATH:$(pwd)/src poetry run python src/agentwatch/cli.py ui

src/agentwatch/event_processor.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class EventProcessor:
2525
NUM_WORKERS = 1
2626

2727
def __init__(self) -> None:
28-
logger.info("agentwatch initializing...")
29-
3028
self._exit_event: Optional[Event] = None
3129
self._init_event: Optional[Event] = None
3230
self._pipe: Optional[Connection] = None
@@ -40,8 +38,6 @@ def __init__(self) -> None:
4038
self._supported_processors: list[type[BaseProcessor]] = [
4139
HttpProcessor
4240
]
43-
44-
logger.debug("agentwatch initialized!")
4541

4642
def start(self, pipe: Connection, init_event: Event, exit_event: Event) -> None:
4743
self._pipe = pipe
@@ -65,7 +61,7 @@ async def _start(self) -> None:
6561

6662
self._register_visualization_webhook()
6763

68-
logger.debug(f"agentwatch up and running")
64+
logger.info(f"agentwatch up and running!")
6965
if self._init_event:
7066
self._init_event.set()
7167

src/agentwatch/graph/models.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import time
22
import uuid
33
from abc import abstractmethod
4-
from typing import Any, Type, TypeAlias
4+
from typing import Any, Optional, Type, TypeAlias
55

66
from pydantic import BaseModel, Field
77

@@ -41,9 +41,13 @@ class ModelGenerateEdge(Edge):
4141
edge_type: EdgeType = EdgeType.MODEL_GENERATE
4242
prompt: str
4343

44+
class Config:
45+
extra = "allow"
46+
4447
class ToolCallEdge(Edge):
4548
edge_type: EdgeType = EdgeType.TOOL_CALL
4649
tool_input: dict[str, Any]
50+
tool_name: Optional[str] = None
4751

4852
GraphStructure: TypeAlias = tuple[list[Node], list[Edge]]
4953

src/agentwatch/llm/anthropic_models.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def extract_graph_structure(self) -> GraphStructure:
3636
if isinstance(content, ToolUse):
3737
tool_call_edge = ToolCallEdge(source_node_id=APP_NODE_ID,
3838
target_node_id=content.name,
39-
tool_input=content.input)
39+
tool_input=content.input,
40+
tool_name=content.name)
4041
edges.append(tool_call_edge)
4142
elif isinstance(content, TextContent):
4243
model_generate_edge = ModelGenerateEdge(prompt=content.text,

src/agentwatch/llm/openai_models.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,16 @@ def extract_graph_structure(self) -> GraphStructure:
5050
for message in self.messages:
5151
if isinstance(message, ToolMessage):
5252
pass
53-
# Not sure I want this
53+
# Not sure I want this, it includes the actual tool call result from the app
5454
# edges.append(ToolCallEdge(source_node_id=APP_NODE_ID,
5555
# target_node_id=self.model,
5656
# tool_input={"input": message.content}))
5757
elif isinstance(message, UserMessage):
5858
edges.append(ModelGenerateEdge(source_node_id=APP_NODE_ID,
5959
target_node_id=self.model,
60-
prompt=message.content))
60+
prompt=message.content,
61+
history_size=len(self.messages))) # type: ignore
6162
elif isinstance(message, AssistantMessage):
62-
for tool_call in message.tool_calls:
63-
edges.append(ToolCallEdge(source_node_id=self.model,
64-
target_node_id=APP_NODE_ID,
65-
tool_input=json.loads(tool_call.function.arguments)))
6663
if message.content is not None:
6764
edges.append(ModelGenerateEdge(source_node_id=self.model,
6865
target_node_id=APP_NODE_ID,
@@ -113,6 +110,14 @@ def extract_graph_structure(self) -> GraphStructure:
113110

114111
for choice in self.choices:
115112
for tool_call in choice.message.tool_calls:
113+
# Two edges should appear here: one edge displays the result from the LLM
114+
# The other one 'simulates' the app call to the tool itself
115+
edges.append(ToolCallEdge(source_node_id=self.model,
116+
target_node_id=APP_NODE_ID,
117+
tool_name=tool_call.function.name,
118+
tool_input=json.loads(tool_call.function.arguments))
119+
)
120+
116121
edges.append(ToolCallEdge(source_node_id=APP_NODE_ID,
117122
target_node_id=tool_call.function.name,
118123
tool_input=json.loads(tool_call.function.arguments)))

src/agentwatch/visualization/frontend/components/Sidebar.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ type EdgeData = Edge & {
99
source: string;
1010
target: string;
1111
data?: {
12-
prompt?: string;
13-
tool_input?: string;
1412
[key: string]: any;
1513
};
1614
};

src/agentwatch/visualization/frontend/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)