agentic-blocks 0.1.23__tar.gz → 0.1.24__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentic_blocks-0.1.23/src/agentic_blocks.egg-info → agentic_blocks-0.1.24}/PKG-INFO +5 -1
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/pyproject.toml +5 -1
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/agent.py +60 -3
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/messages.py +18 -8
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24/src/agentic_blocks.egg-info}/PKG-INFO +5 -1
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks.egg-info/requires.txt +4 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/LICENSE +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/README.md +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/setup.cfg +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/__init__.py +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/llm.py +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/mcp_client.py +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/utils/tools_utils.py +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/visualization/visualize.py +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks.egg-info/SOURCES.txt +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks.egg-info/dependency_links.txt +0 -0
- {agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: agentic-blocks
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.24
|
4
4
|
Summary: Simple building blocks for agentic AI systems with MCP client and conversation management
|
5
5
|
Author-email: Magnus Bjelkenhed <bjelkenhed@gmail.com>
|
6
6
|
License: MIT
|
@@ -27,6 +27,10 @@ Requires-Dist: langchain-core
|
|
27
27
|
Requires-Dist: langfuse
|
28
28
|
Requires-Dist: pocketflow
|
29
29
|
Requires-Dist: pocketflow-tracing
|
30
|
+
Requires-Dist: agno
|
31
|
+
Requires-Dist: ipywidgets
|
32
|
+
Requires-Dist: rich[jupyter]
|
33
|
+
Requires-Dist: fastapi
|
30
34
|
Provides-Extra: test
|
31
35
|
Requires-Dist: pytest; extra == "test"
|
32
36
|
Provides-Extra: dev
|
@@ -14,7 +14,7 @@ agentic_blocks = []
|
|
14
14
|
|
15
15
|
[project]
|
16
16
|
name = "agentic-blocks"
|
17
|
-
version = "0.1.
|
17
|
+
version = "0.1.24"
|
18
18
|
description = "Simple building blocks for agentic AI systems with MCP client and conversation management"
|
19
19
|
readme = "README.md"
|
20
20
|
requires-python = ">=3.11"
|
@@ -43,6 +43,10 @@ dependencies = [
|
|
43
43
|
"langfuse",
|
44
44
|
"pocketflow",
|
45
45
|
"pocketflow-tracing",
|
46
|
+
"agno",
|
47
|
+
"ipywidgets",
|
48
|
+
"rich[jupyter]",
|
49
|
+
"fastapi",
|
46
50
|
]
|
47
51
|
|
48
52
|
[project.urls]
|
@@ -4,6 +4,18 @@ from agentic_blocks.utils.tools_utils import (
|
|
4
4
|
execute_pending_tool_calls,
|
5
5
|
)
|
6
6
|
from agentic_blocks import call_llm, Messages
|
7
|
+
from rich.panel import Panel
|
8
|
+
from rich.box import HEAVY
|
9
|
+
from rich.console import Console
|
10
|
+
from rich.console import Group
|
11
|
+
|
12
|
+
console = Console(
|
13
|
+
style="black on bright_white",
|
14
|
+
force_terminal=True,
|
15
|
+
width=None,
|
16
|
+
legacy_windows=False,
|
17
|
+
color_system="truecolor",
|
18
|
+
)
|
7
19
|
|
8
20
|
|
9
21
|
class Agent:
|
@@ -11,6 +23,7 @@ class Agent:
|
|
11
23
|
self.system_prompt = system_prompt
|
12
24
|
self.tools = tools
|
13
25
|
self.tool_registry = create_tool_registry(tools)
|
26
|
+
self.panels = []
|
14
27
|
|
15
28
|
# Create nodes
|
16
29
|
self.llm_node = self._create_llm_node()
|
@@ -32,7 +45,8 @@ class Agent:
|
|
32
45
|
self.tools = tools
|
33
46
|
|
34
47
|
def prep(self, shared):
|
35
|
-
|
48
|
+
messages = shared["messages"]
|
49
|
+
return messages
|
36
50
|
|
37
51
|
def exec(self, messages) -> Messages:
|
38
52
|
response = call_llm(messages=messages, tools=self.tools)
|
@@ -49,14 +63,31 @@ class Agent:
|
|
49
63
|
|
50
64
|
def _create_tool_node(self):
|
51
65
|
class ToolNode(Node):
|
52
|
-
def __init__(self, tool_registry):
|
66
|
+
def __init__(self, tool_registry, agent):
|
53
67
|
super().__init__()
|
54
68
|
self.tool_registry = tool_registry
|
69
|
+
self.agent = agent
|
55
70
|
|
56
71
|
def prep(self, shared):
|
57
72
|
return shared["messages"]
|
58
73
|
|
59
74
|
def exec(self, messages) -> Messages:
|
75
|
+
tool_calls = messages.get_pending_tool_calls()[0]
|
76
|
+
tool_name = tool_calls["tool_name"]
|
77
|
+
tool_arguments = tool_calls["arguments"]
|
78
|
+
|
79
|
+
# Format arguments nicely
|
80
|
+
if isinstance(tool_arguments, dict):
|
81
|
+
args_str = ", ".join(
|
82
|
+
[f"{k}={v}" for k, v in tool_arguments.items()]
|
83
|
+
)
|
84
|
+
formatted_call = f"{tool_name}({args_str})"
|
85
|
+
else:
|
86
|
+
formatted_call = f"{tool_name}({tool_arguments})"
|
87
|
+
|
88
|
+
tool_panel = self.agent.create_panel(formatted_call, "Tool Calls")
|
89
|
+
self.agent.panels.append(tool_panel)
|
90
|
+
|
60
91
|
tool_responses = execute_pending_tool_calls(
|
61
92
|
messages, self.tool_registry
|
62
93
|
)
|
@@ -66,7 +97,7 @@ class Agent:
|
|
66
97
|
def post(self, shared, prep_res, messages):
|
67
98
|
return "llm_node"
|
68
99
|
|
69
|
-
return ToolNode(self.tool_registry)
|
100
|
+
return ToolNode(self.tool_registry, self)
|
70
101
|
|
71
102
|
def _create_answer_node(self):
|
72
103
|
class AnswerNode(Node):
|
@@ -86,3 +117,29 @@ class Agent:
|
|
86
117
|
self.flow.run(shared)
|
87
118
|
|
88
119
|
return shared["answer"]
|
120
|
+
|
121
|
+
def print_response(self, user_prompt: str, stream: bool = False):
|
122
|
+
# Reset panels and start with message
|
123
|
+
self.panels = []
|
124
|
+
message_panel = self.create_panel(user_prompt, "Message")
|
125
|
+
self.panels.append(message_panel)
|
126
|
+
|
127
|
+
# Always collect all panels first
|
128
|
+
response = self.invoke(user_prompt)
|
129
|
+
response_panel = self.create_panel(response, "Response")
|
130
|
+
self.panels.append(response_panel)
|
131
|
+
|
132
|
+
# Print all panels as a group (no gaps)
|
133
|
+
panel_group = Group(*self.panel)
|
134
|
+
console.print(panel_group)
|
135
|
+
|
136
|
+
def create_panel(self, content, title, border_style="blue"):
|
137
|
+
return Panel(
|
138
|
+
content,
|
139
|
+
title=title,
|
140
|
+
title_align="left",
|
141
|
+
border_style=border_style,
|
142
|
+
box=HEAVY,
|
143
|
+
expand=True, # Full terminal width
|
144
|
+
padding=(1, 1), # Internal padding
|
145
|
+
)
|
@@ -175,6 +175,13 @@ class Messages:
|
|
175
175
|
"""Get the current messages list."""
|
176
176
|
return self.messages
|
177
177
|
|
178
|
+
def get_user_message(self) -> str:
|
179
|
+
"""Get the user message."""
|
180
|
+
for message in reversed(self.messages):
|
181
|
+
if message.get("role") == "user":
|
182
|
+
return message.get("content") or ""
|
183
|
+
return ""
|
184
|
+
|
178
185
|
def has_pending_tool_calls(self) -> bool:
|
179
186
|
"""
|
180
187
|
Check if the last message has tool calls that need execution.
|
@@ -213,7 +220,7 @@ class Messages:
|
|
213
220
|
List of dictionaries with 'tool_name', 'arguments', and 'tool_call_id' keys
|
214
221
|
"""
|
215
222
|
pending_calls = []
|
216
|
-
|
223
|
+
|
217
224
|
if not self.messages:
|
218
225
|
return pending_calls
|
219
226
|
|
@@ -234,19 +241,22 @@ class Messages:
|
|
234
241
|
function_info = tool_call.get("function", {})
|
235
242
|
tool_name = function_info.get("name")
|
236
243
|
arguments_str = function_info.get("arguments", "{}")
|
237
|
-
|
244
|
+
|
238
245
|
# Parse arguments JSON string to dict
|
239
246
|
import json
|
247
|
+
|
240
248
|
try:
|
241
249
|
arguments = json.loads(arguments_str)
|
242
250
|
except json.JSONDecodeError:
|
243
251
|
arguments = {}
|
244
|
-
|
245
|
-
pending_calls.append(
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
252
|
+
|
253
|
+
pending_calls.append(
|
254
|
+
{
|
255
|
+
"tool_name": tool_name,
|
256
|
+
"arguments": arguments,
|
257
|
+
"tool_call_id": tool_call_id,
|
258
|
+
}
|
259
|
+
)
|
250
260
|
|
251
261
|
return pending_calls
|
252
262
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: agentic-blocks
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.24
|
4
4
|
Summary: Simple building blocks for agentic AI systems with MCP client and conversation management
|
5
5
|
Author-email: Magnus Bjelkenhed <bjelkenhed@gmail.com>
|
6
6
|
License: MIT
|
@@ -27,6 +27,10 @@ Requires-Dist: langchain-core
|
|
27
27
|
Requires-Dist: langfuse
|
28
28
|
Requires-Dist: pocketflow
|
29
29
|
Requires-Dist: pocketflow-tracing
|
30
|
+
Requires-Dist: agno
|
31
|
+
Requires-Dist: ipywidgets
|
32
|
+
Requires-Dist: rich[jupyter]
|
33
|
+
Requires-Dist: fastapi
|
30
34
|
Provides-Extra: test
|
31
35
|
Requires-Dist: pytest; extra == "test"
|
32
36
|
Provides-Extra: dev
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks/visualization/visualize.py
RENAMED
File without changes
|
File without changes
|
{agentic_blocks-0.1.23 → agentic_blocks-0.1.24}/src/agentic_blocks.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|