Skip to content

Commit 52e9111

Browse files
committed
feat: update beeai-framework
Signed-off-by: Tomas Dvorak <[email protected]>
1 parent e51b16a commit 52e9111

File tree

15 files changed

+337
-228
lines changed

15 files changed

+337
-228
lines changed

agents/chat/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
]
88
requires-python = ">=3.13,<3.14"
99
dependencies = [
10-
"beeai-framework[duckduckgo,wikipedia]>=0.1.60",
10+
"beeai-framework[duckduckgo,wikipedia]>=0.1.67",
1111
"tiktoken>=0.12.0", # constraint for beeai-framework dependency (first version with musl arm64 wheel)
1212
"fastuuid>=0.14.0", # constraint for beeai-framework dependency (first version with musl arm64 wheel)
1313
"openai>=1.107.1",

agents/chat/src/chat/tools/general/act.py

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
from typing import Literal
55

6-
from beeai_framework.agents.experimental import (
6+
from beeai_framework.agents.requirement import (
77
RequirementAgent,
88
RequirementAgentRunState,
99
)
10-
from beeai_framework.agents.experimental.events import RequirementAgentStartEvent
11-
from beeai_framework.agents.experimental.requirements import Requirement, Rule
12-
from beeai_framework.agents.experimental.requirements.requirement import (
10+
from beeai_framework.agents.requirement.events import RequirementAgentStartEvent
11+
from beeai_framework.agents.requirement.requirements import Requirement, Rule
12+
from beeai_framework.agents.requirement.requirements.requirement import (
1313
run_with_context,
1414
)
1515
from beeai_framework.context import RunContext
@@ -29,11 +29,15 @@ class ActToolInput(BaseModel):
2929
...,
3030
description="Provide a clear explanation of why you want to use the selected tool and what you expect to achieve.",
3131
)
32-
selected_tool: str = Field(..., description="The name of the tool you want to execute next.")
32+
selected_tool: str = Field(
33+
..., description="The name of the tool you want to execute next."
34+
)
3335

3436

3537
class ActToolResult(BaseModel):
36-
selected_tool: str = Field(..., description="The name of the tool that has been selected for execution.")
38+
selected_tool: str = Field(
39+
..., description="The name of the tool that has been selected for execution."
40+
)
3741

3842

3943
class ActToolOutput(JSONToolOutput[ActToolResult]):
@@ -98,7 +102,9 @@ def allowed_tools_names(self, allowed_tools_names: list[str]) -> None:
98102
def input_schema(self):
99103
return self._input_schema
100104

101-
async def _run(self, input: ActToolInput, options: ToolRunOptions | None, context: RunContext) -> ActToolOutput:
105+
async def _run(
106+
self, input: ActToolInput, options: ToolRunOptions | None, context: RunContext
107+
) -> ActToolOutput:
102108
if not input.selected_tool:
103109
raise ToolInputValidationError(
104110
f"You must always select one of the provided tools: {self._allowed_tools_names}."
@@ -147,21 +153,53 @@ async def run(self, state: RequirementAgentRunState, ctx: RunContext) -> list[Ru
147153
if last_step and last_step.tool and last_step.tool.name == "act":
148154
assert isinstance(last_step.tool, ActTool)
149155
if last_step.error is not None:
150-
return [Rule(target="act", forced=True, allowed=True, prevent_stop=False, hidden=False)]
151-
152-
if last_step.output is None or not isinstance(last_step.output, ActToolOutput):
153-
raise ValueError("Last step output must be an instance of ActToolOutput.")
156+
return [
157+
Rule(
158+
target="act",
159+
forced=True,
160+
allowed=True,
161+
prevent_stop=False,
162+
hidden=False,
163+
)
164+
]
165+
166+
if last_step.output is None or not isinstance(
167+
last_step.output, ActToolOutput
168+
):
169+
raise ValueError(
170+
"Last step output must be an instance of ActToolOutput."
171+
)
154172
selected_tool = last_step.output.result.selected_tool
155-
return [Rule(target=selected_tool, forced=True, allowed=True, prevent_stop=False, hidden=False)]
173+
return [
174+
Rule(
175+
target=selected_tool,
176+
forced=True,
177+
allowed=True,
178+
prevent_stop=False,
179+
hidden=False,
180+
)
181+
]
156182

157183
# Hide all tools except ActTool on the first step
158184
rules = [
159-
Rule(target=t.name, hidden=True, allowed=False, prevent_stop=False, forced=False)
185+
Rule(
186+
target=t.name,
187+
hidden=True,
188+
allowed=False,
189+
prevent_stop=False,
190+
forced=False,
191+
)
160192
for t in self.tools
161193
if not isinstance(t, ActTool)
162194
]
163195
return [
164-
Rule(target="act", forced=True, allowed=True, prevent_stop=False, hidden=False),
196+
Rule(
197+
target="act",
198+
forced=True,
199+
allowed=True,
200+
prevent_stop=False,
201+
hidden=False,
202+
),
165203
*rules,
166204
]
167205

agents/chat/src/chat/tools/general/clarification.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Copyright 2025 © BeeAI a Series of LF Projects, LLC
22
# SPDX-License-Identifier: Apache-2.0
33

4-
from beeai_framework.agents.experimental import (
4+
from beeai_framework.agents.requirement import (
55
RequirementAgent,
66
RequirementAgentRunState,
77
)
8-
from beeai_framework.agents.experimental.events import RequirementAgentStartEvent
8+
from beeai_framework.agents.requirement.events import RequirementAgentStartEvent
99
from beeai_framework.backend import AssistantMessage
1010
from beeai_framework.context import RunContext
1111
from beeai_framework.emitter import Emitter, EventMeta
@@ -20,10 +20,13 @@
2020

2121
class ClarificationSchema(BaseModel):
2222
thoughts: str = Field(
23-
..., description="Your reasoning process and analysis of what information is needed from the user."
23+
...,
24+
description="Your reasoning process and analysis of what information is needed from the user.",
2425
)
2526
question_to_user: str = Field(
26-
..., description="The specific question or clarification request to ask the user.", min_length=1
27+
...,
28+
description="The specific question or clarification request to ask the user.",
29+
min_length=1,
2730
)
2831

2932

@@ -63,7 +66,9 @@ async def _run(
6366
context: RunContext,
6467
) -> StringToolOutput:
6568
if not self._state:
66-
raise ToolInputValidationError("State is not set for the ClarificationTool.")
69+
raise ToolInputValidationError(
70+
"State is not set for the ClarificationTool."
71+
)
6772

6873
# Store the clarification request in the agent state
6974
self._state.result = input
@@ -85,7 +90,9 @@ def clarification_tool_middleware(ctx: RunContext) -> None:
8590
"""
8691
assert isinstance(ctx.instance, RequirementAgent)
8792

88-
clarification_tool = next((t for t in ctx.instance._tools if isinstance(t, ClarificationTool)), None)
93+
clarification_tool = next(
94+
(t for t in ctx.instance._tools if isinstance(t, ClarificationTool)), None
95+
)
8996
if clarification_tool is None:
9097
raise ValueError("ClarificationTool is not found in the agent's tools.")
9198

0 commit comments

Comments
 (0)