Skip to content

Commit 8c00889

Browse files
dsowinski2rafalcymerys
authored andcommitted
feat: Add tool calling versions of example agents, handle tool calling agent memory
1 parent f929b5a commit 8c00889

File tree

30 files changed

+232
-23
lines changed

30 files changed

+232
-23
lines changed

plugins/enthusiast-agent-catalog-enrichment/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "enthusiast-agent-catalog-enrichment"
3-
version = "1.1.2"
3+
version = "1.2.0"
44
description = "Example implementation of a catalog enrichment ReAct agent for Enthusiast"
55
authors = [
66
{name = "Damian Sowiński",email = "damian.sowinski@upsidelab.io"}
@@ -10,7 +10,8 @@ requires-python = ">=3.10,<4"
1010
dependencies = [
1111
"enthusiast-common (>=1.4.0,<2.0.0)",
1212
"langchain (>=0.3.26,<0.4.0)",
13-
"enthusiast_agent_re_act (>=1.2.0)"
13+
"enthusiast_agent_re_act (>=1.2.0)",
14+
"enthusiast_agent_tool_calling (>=1.0.0)"
1415
]
1516

1617
[tool.poetry]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from enthusiast_agent_tool_calling import BaseToolCallingAgent
2+
from enthusiast_common.utils import RequiredFieldsModel
3+
from pydantic import Field, Json
4+
5+
6+
class ExtractDataPromptInput(RequiredFieldsModel):
7+
output_format: Json = Field(title="Output format", description="Output format of the extracted data")
8+
9+
10+
class CatalogEnrichmentToolCallingAgent(BaseToolCallingAgent):
11+
PROMPT_INPUT = ExtractDataPromptInput
12+
FILE_UPLOAD = True
13+
14+
def get_answer(self, input_text: str) -> str:
15+
agent_executor = self._build_agent_executor()
16+
agent_output = agent_executor.invoke(
17+
{"input": input_text, "data_format": self.PROMPT_INPUT.output_format}, config=self._build_invoke_config()
18+
)
19+
return agent_output["output"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from enthusiast_common.config import AgentConfigWithDefaults
2+
from enthusiast_common.config.prompts import ChatPromptTemplateConfig, Message, MessageRole
3+
4+
from .agent import CatalogEnrichmentToolCallingAgent
5+
from .prompt import DATA_EXTRACTION_TOOL_CALLING_AGENT_PROMPT
6+
7+
8+
def get_config() -> AgentConfigWithDefaults:
9+
return AgentConfigWithDefaults(
10+
prompt_template=ChatPromptTemplateConfig(
11+
messages=[
12+
Message(
13+
role=MessageRole.SYSTEM,
14+
content=DATA_EXTRACTION_TOOL_CALLING_AGENT_PROMPT,
15+
),
16+
Message(role=MessageRole.PLACEHOLDER, content="{chat_history}"),
17+
Message(role=MessageRole.USER, content="{input}"),
18+
Message(role=MessageRole.PLACEHOLDER, content="{agent_scratchpad}"),
19+
]
20+
),
21+
agent_class=CatalogEnrichmentToolCallingAgent,
22+
tools=CatalogEnrichmentToolCallingAgent.TOOLS,
23+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DATA_EXTRACTION_TOOL_CALLING_AGENT_PROMPT = """
2+
I want you to help extracting and describing in details attributes for products.
3+
In case of any missing information carefully collect it one by one.
4+
In tools specify exactly what are you looking for.
5+
If there are more variants return all of them.
6+
You need to return variant data in given shape: {data_format}.
7+
Always verify your answer
8+
Return only json
9+
"""

plugins/enthusiast-agent-ocr-to-order/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "enthusiast-agent-ocr-to-order"
3-
version = "1.1.2"
3+
version = "1.2.0"
44
description = "Example implementation of a OCR to order ReAct agent for Enthusiast"
55
authors = [
66
{name = "Damian Sowiński",email = "damian.sowinski@upsidelab.io"}
@@ -10,7 +10,8 @@ requires-python = ">=3.10,<4"
1010
dependencies = [
1111
"enthusiast-common (>=1.4.0,<2.0.0)",
1212
"langchain (>=0.3.26,<0.4.0)",
13-
"enthusiast_agent_re_act (>=1.2.0)"
13+
"enthusiast_agent_re_act (>=1.2.0)",
14+
"enthusiast_agent_tool_calling (>=1.0.0)"
1415
]
1516

1617
[tool.poetry]

plugins/enthusiast-agent-ocr-to-order/src/enthusiast_agent_ocr_to_order/agent.py renamed to plugins/enthusiast-agent-ocr-to-order/src/enthusiast_agent_ocr_to_order/re_act/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from langchain.agents import AgentExecutor, create_react_agent
44
from langchain_core.tools import render_text_description_and_args
55

6-
from .tools.place_order_tool import OrderPlacementTool
7-
from .tools.product_search_tool import ProductSearchTool
6+
from ..tools.place_order_tool import OrderPlacementTool
7+
from ..tools.product_search_tool import ProductSearchTool
88

99

1010
class OCROrderReActAgent(BaseReActAgent):

0 commit comments

Comments
 (0)