2024-11-10 11:44:01 +00:00
|
|
|
"""
|
|
|
|
|
Simple agent infrastructure broadly implements the ReAct flow.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
import re
|
|
|
|
|
import sys
|
2025-07-08 16:19:19 +01:00
|
|
|
import functools
|
2025-07-21 14:31:57 +01:00
|
|
|
import logging
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
# Module logger
|
2025-07-21 14:31:57 +01:00
|
|
|
logger = logging.getLogger(__name__)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
from ... base import AgentService, TextCompletionClientSpec, PromptClientSpec
|
2025-09-04 16:23:43 +01:00
|
|
|
from ... base import GraphRagClientSpec, ToolClientSpec, StructuredQueryClientSpec
|
2025-04-22 20:21:38 +01:00
|
|
|
|
|
|
|
|
from ... schema import AgentRequest, AgentResponse, AgentStep, Error
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-09-04 16:23:43 +01:00
|
|
|
from . tools import KnowledgeQueryImpl, TextCompletionImpl, McpToolImpl, PromptImpl, StructuredQueryImpl
|
2024-11-10 11:44:01 +00:00
|
|
|
from . agent_manager import AgentManager
|
2025-09-03 23:39:49 +01:00
|
|
|
from ..tool_filter import validate_tool_config, filter_tools_by_group_and_state, get_next_state
|
2024-11-10 11:44:01 +00:00
|
|
|
|
|
|
|
|
from . types import Final, Action, Tool, Argument
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
default_ident = "agent-manager"
|
|
|
|
|
default_max_iterations = 10
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
class Processor(AgentService):
|
2024-11-10 11:44:01 +00:00
|
|
|
|
|
|
|
|
def __init__(self, **params):
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
id = params.get("id")
|
|
|
|
|
|
2025-04-02 16:37:08 +01:00
|
|
|
self.max_iterations = int(
|
|
|
|
|
params.get("max_iterations", default_max_iterations)
|
|
|
|
|
)
|
2024-11-19 21:28:47 +00:00
|
|
|
|
2025-04-02 16:37:08 +01:00
|
|
|
self.config_key = params.get("config_type", "agent")
|
|
|
|
|
|
2024-11-10 11:44:01 +00:00
|
|
|
super(Processor, self).__init__(
|
|
|
|
|
**params | {
|
2025-04-22 20:21:38 +01:00
|
|
|
"id": id,
|
|
|
|
|
"max_iterations": self.max_iterations,
|
|
|
|
|
"config_type": self.config_key,
|
2024-11-10 11:44:01 +00:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
self.agent = AgentManager(
|
2025-08-21 13:00:33 +01:00
|
|
|
tools={},
|
2025-04-22 20:21:38 +01:00
|
|
|
additional_context="",
|
2024-11-10 11:44:01 +00:00
|
|
|
)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
self.config_handlers.append(self.on_tools_config)
|
|
|
|
|
|
|
|
|
|
self.register_specification(
|
|
|
|
|
TextCompletionClientSpec(
|
|
|
|
|
request_name = "text-completion-request",
|
|
|
|
|
response_name = "text-completion-response",
|
|
|
|
|
)
|
2024-11-10 11:44:01 +00:00
|
|
|
)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
self.register_specification(
|
|
|
|
|
GraphRagClientSpec(
|
|
|
|
|
request_name = "graph-rag-request",
|
|
|
|
|
response_name = "graph-rag-response",
|
|
|
|
|
)
|
2024-11-10 11:44:01 +00:00
|
|
|
)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
self.register_specification(
|
|
|
|
|
PromptClientSpec(
|
|
|
|
|
request_name = "prompt-request",
|
|
|
|
|
response_name = "prompt-response",
|
|
|
|
|
)
|
2024-11-10 11:44:01 +00:00
|
|
|
)
|
|
|
|
|
|
2025-07-08 16:19:19 +01:00
|
|
|
self.register_specification(
|
|
|
|
|
ToolClientSpec(
|
|
|
|
|
request_name = "mcp-tool-request",
|
|
|
|
|
response_name = "mcp-tool-response",
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-04 16:23:43 +01:00
|
|
|
self.register_specification(
|
|
|
|
|
StructuredQueryClientSpec(
|
|
|
|
|
request_name = "structured-query-request",
|
|
|
|
|
response_name = "structured-query-response",
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
async def on_tools_config(self, config, version):
|
2025-04-02 16:37:08 +01:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.info(f"Loading configuration version {version}")
|
2025-04-02 16:37:08 +01:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
tools = {}
|
|
|
|
|
|
2025-07-16 23:09:32 +01:00
|
|
|
# Load tool configurations from the new location
|
|
|
|
|
if "tool" in config:
|
|
|
|
|
for tool_id, tool_value in config["tool"].items():
|
|
|
|
|
data = json.loads(tool_value)
|
|
|
|
|
|
|
|
|
|
impl_id = data.get("type")
|
|
|
|
|
name = data.get("name")
|
|
|
|
|
|
|
|
|
|
# Create the appropriate implementation
|
|
|
|
|
if impl_id == "knowledge-query":
|
|
|
|
|
impl = functools.partial(
|
|
|
|
|
KnowledgeQueryImpl,
|
|
|
|
|
collection=data.get("collection")
|
|
|
|
|
)
|
|
|
|
|
arguments = KnowledgeQueryImpl.get_arguments()
|
|
|
|
|
elif impl_id == "text-completion":
|
|
|
|
|
impl = TextCompletionImpl
|
|
|
|
|
arguments = TextCompletionImpl.get_arguments()
|
|
|
|
|
elif impl_id == "mcp-tool":
|
2025-08-21 14:46:10 +01:00
|
|
|
# For MCP tools, arguments come from config (similar to prompt tools)
|
|
|
|
|
config_args = data.get("arguments", [])
|
|
|
|
|
arguments = [
|
|
|
|
|
Argument(
|
|
|
|
|
name=arg.get("name"),
|
|
|
|
|
type=arg.get("type"),
|
|
|
|
|
description=arg.get("description")
|
|
|
|
|
)
|
|
|
|
|
for arg in config_args
|
|
|
|
|
]
|
2025-07-16 23:09:32 +01:00
|
|
|
impl = functools.partial(
|
|
|
|
|
McpToolImpl,
|
2025-08-21 14:46:10 +01:00
|
|
|
mcp_tool_id=data.get("mcp-tool"),
|
|
|
|
|
arguments=arguments
|
2025-07-16 23:09:32 +01:00
|
|
|
)
|
|
|
|
|
elif impl_id == "prompt":
|
|
|
|
|
# For prompt tools, arguments come from config
|
|
|
|
|
config_args = data.get("arguments", [])
|
|
|
|
|
arguments = [
|
|
|
|
|
Argument(
|
|
|
|
|
name=arg.get("name"),
|
|
|
|
|
type=arg.get("type"),
|
|
|
|
|
description=arg.get("description")
|
|
|
|
|
)
|
|
|
|
|
for arg in config_args
|
|
|
|
|
]
|
|
|
|
|
impl = functools.partial(
|
|
|
|
|
PromptImpl,
|
|
|
|
|
template_id=data.get("template"),
|
|
|
|
|
arguments=arguments
|
|
|
|
|
)
|
2025-09-04 16:23:43 +01:00
|
|
|
elif impl_id == "structured-query":
|
|
|
|
|
impl = functools.partial(
|
|
|
|
|
StructuredQueryImpl,
|
2025-09-08 18:28:38 +01:00
|
|
|
collection=data.get("collection"),
|
|
|
|
|
user=None # User will be provided dynamically via context
|
2025-09-04 16:23:43 +01:00
|
|
|
)
|
|
|
|
|
arguments = StructuredQueryImpl.get_arguments()
|
2025-07-16 23:09:32 +01:00
|
|
|
else:
|
|
|
|
|
raise RuntimeError(
|
|
|
|
|
f"Tool type {impl_id} not known"
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-03 23:39:49 +01:00
|
|
|
# Validate tool configuration
|
|
|
|
|
validate_tool_config(data)
|
|
|
|
|
|
2025-07-16 23:09:32 +01:00
|
|
|
tools[name] = Tool(
|
|
|
|
|
name=name,
|
|
|
|
|
description=data.get("description"),
|
|
|
|
|
implementation=impl,
|
|
|
|
|
config=data, # Store full config for reference
|
|
|
|
|
arguments=arguments,
|
2025-04-02 16:37:08 +01:00
|
|
|
)
|
2025-07-16 23:09:32 +01:00
|
|
|
|
|
|
|
|
# Load additional context from agent config if it exists
|
|
|
|
|
additional = None
|
|
|
|
|
if self.config_key in config:
|
|
|
|
|
agent_config = config[self.config_key]
|
|
|
|
|
additional = agent_config.get("additional-context", None)
|
|
|
|
|
|
2025-04-02 16:37:08 +01:00
|
|
|
self.agent = AgentManager(
|
|
|
|
|
tools=tools,
|
|
|
|
|
additional_context=additional
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.info(f"Loaded {len(tools)} tools")
|
|
|
|
|
logger.info("Tool configuration reloaded.")
|
2025-04-02 16:37:08 +01:00
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.error(f"on_tools_config Exception: {e}", exc_info=True)
|
|
|
|
|
logger.error("Configuration reload failed")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
async def agent_request(self, request, respond, next, flow):
|
2024-11-10 11:44:01 +00:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
2025-11-26 09:59:10 +00:00
|
|
|
# Check if streaming is enabled
|
|
|
|
|
streaming = getattr(request, 'streaming', False)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
if request.history:
|
2024-11-10 11:44:01 +00:00
|
|
|
history = [
|
|
|
|
|
Action(
|
|
|
|
|
thought=h.thought,
|
|
|
|
|
name=h.action,
|
|
|
|
|
arguments=h.arguments,
|
|
|
|
|
observation=h.observation
|
|
|
|
|
)
|
2025-04-22 20:21:38 +01:00
|
|
|
for h in request.history
|
2024-11-10 11:44:01 +00:00
|
|
|
]
|
|
|
|
|
else:
|
|
|
|
|
history = []
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.info(f"Question: {request.question}")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2024-11-19 21:28:47 +00:00
|
|
|
if len(history) >= self.max_iterations:
|
2024-11-10 11:44:01 +00:00
|
|
|
raise RuntimeError("Too many agent iterations")
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug(f"History: {history}")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-02-15 12:25:26 +00:00
|
|
|
async def think(x):
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug(f"Think: {x}")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-11-26 09:59:10 +00:00
|
|
|
if streaming:
|
|
|
|
|
# Streaming format
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
chunk_type="thought",
|
|
|
|
|
content=x,
|
|
|
|
|
end_of_message=True,
|
|
|
|
|
end_of_dialog=False,
|
|
|
|
|
# Legacy fields for backward compatibility
|
|
|
|
|
answer=None,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=x,
|
|
|
|
|
observation=None,
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
# Legacy format
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
answer=None,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=x,
|
|
|
|
|
observation=None,
|
|
|
|
|
)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
await respond(r)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-02-15 12:25:26 +00:00
|
|
|
async def observe(x):
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug(f"Observe: {x}")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-11-26 09:59:10 +00:00
|
|
|
if streaming:
|
|
|
|
|
# Streaming format
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
chunk_type="observation",
|
|
|
|
|
content=x,
|
|
|
|
|
end_of_message=True,
|
|
|
|
|
end_of_dialog=False,
|
|
|
|
|
# Legacy fields for backward compatibility
|
|
|
|
|
answer=None,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=None,
|
|
|
|
|
observation=x,
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
# Legacy format
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
answer=None,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=None,
|
|
|
|
|
observation=x,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await respond(r)
|
|
|
|
|
|
|
|
|
|
async def answer(x):
|
|
|
|
|
|
|
|
|
|
logger.debug(f"Answer: {x}")
|
|
|
|
|
|
|
|
|
|
if streaming:
|
|
|
|
|
# Streaming format
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
chunk_type="answer",
|
|
|
|
|
content=x,
|
|
|
|
|
end_of_message=False, # More chunks may follow
|
|
|
|
|
end_of_dialog=False,
|
|
|
|
|
# Legacy fields for backward compatibility
|
|
|
|
|
answer=None,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=None,
|
|
|
|
|
observation=None,
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
# Legacy format - shouldn't be called in non-streaming mode
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
answer=x,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=None,
|
|
|
|
|
observation=None,
|
|
|
|
|
)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
await respond(r)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-09-03 23:39:49 +01:00
|
|
|
# Apply tool filtering based on request groups and state
|
|
|
|
|
filtered_tools = filter_tools_by_group_and_state(
|
|
|
|
|
tools=self.agent.tools,
|
|
|
|
|
requested_groups=getattr(request, 'group', None),
|
|
|
|
|
current_state=getattr(request, 'state', None)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
logger.info(f"Filtered from {len(self.agent.tools)} to {len(filtered_tools)} available tools")
|
|
|
|
|
|
|
|
|
|
# Create temporary agent with filtered tools
|
|
|
|
|
temp_agent = AgentManager(
|
|
|
|
|
tools=filtered_tools,
|
|
|
|
|
additional_context=self.agent.additional_context
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug("Call React")
|
2025-07-08 16:19:19 +01:00
|
|
|
|
2025-09-08 18:28:38 +01:00
|
|
|
# Create user-aware context wrapper that preserves the flow interface
|
|
|
|
|
# but adds user information for tools that need it
|
|
|
|
|
class UserAwareContext:
|
|
|
|
|
def __init__(self, flow, user):
|
|
|
|
|
self._flow = flow
|
|
|
|
|
self._user = user
|
|
|
|
|
|
|
|
|
|
def __call__(self, service_name):
|
|
|
|
|
client = self._flow(service_name)
|
|
|
|
|
# For structured query clients, store user context
|
|
|
|
|
if service_name == "structured-query-request":
|
|
|
|
|
client._current_user = self._user
|
|
|
|
|
return client
|
|
|
|
|
|
2025-09-03 23:39:49 +01:00
|
|
|
act = await temp_agent.react(
|
2025-04-22 20:21:38 +01:00
|
|
|
question = request.question,
|
|
|
|
|
history = history,
|
|
|
|
|
think = think,
|
|
|
|
|
observe = observe,
|
2025-11-26 09:59:10 +00:00
|
|
|
answer = answer,
|
2025-09-08 18:28:38 +01:00
|
|
|
context = UserAwareContext(flow, request.user),
|
2025-11-26 09:59:10 +00:00
|
|
|
streaming = streaming,
|
2025-04-22 20:21:38 +01:00
|
|
|
)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug(f"Action: {act}")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
if isinstance(act, Final):
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug("Send final response...")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-21 14:31:57 +01:00
|
|
|
if isinstance(act.final, str):
|
|
|
|
|
f = act.final
|
|
|
|
|
else:
|
|
|
|
|
f = json.dumps(act.final)
|
|
|
|
|
|
2025-11-26 09:59:10 +00:00
|
|
|
if streaming:
|
|
|
|
|
# Streaming format - send end-of-dialog marker
|
|
|
|
|
# Answer chunks were already sent via think() callback during parsing
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
chunk_type="answer",
|
|
|
|
|
content="", # Empty content, just marking end of dialog
|
|
|
|
|
end_of_message=True,
|
|
|
|
|
end_of_dialog=True,
|
|
|
|
|
# Legacy fields for backward compatibility
|
|
|
|
|
answer=act.final,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=None,
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
# Legacy format - send complete answer
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
answer=act.final,
|
|
|
|
|
error=None,
|
|
|
|
|
thought=None,
|
|
|
|
|
)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
await respond(r)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug("Done.")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug("Send next...")
|
2025-04-22 20:21:38 +01:00
|
|
|
|
2024-11-10 11:44:01 +00:00
|
|
|
history.append(act)
|
2025-09-03 23:39:49 +01:00
|
|
|
|
|
|
|
|
# Handle state transitions if tool execution was successful
|
|
|
|
|
next_state = request.state
|
|
|
|
|
if act.name in filtered_tools:
|
|
|
|
|
executed_tool = filtered_tools[act.name]
|
|
|
|
|
next_state = get_next_state(executed_tool, request.state or "undefined")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
|
|
|
|
r = AgentRequest(
|
2025-04-22 20:21:38 +01:00
|
|
|
question=request.question,
|
2025-09-03 23:39:49 +01:00
|
|
|
state=next_state,
|
|
|
|
|
group=getattr(request, 'group', []),
|
2024-11-10 11:44:01 +00:00
|
|
|
history=[
|
|
|
|
|
AgentStep(
|
|
|
|
|
thought=h.thought,
|
|
|
|
|
action=h.name,
|
2025-11-11 12:28:53 +00:00
|
|
|
arguments={k: str(v) for k, v in h.arguments.items()},
|
2024-11-10 11:44:01 +00:00
|
|
|
observation=h.observation
|
|
|
|
|
)
|
|
|
|
|
for h in history
|
2025-11-26 09:59:10 +00:00
|
|
|
],
|
|
|
|
|
user=request.user,
|
|
|
|
|
streaming=streaming,
|
2024-11-10 11:44:01 +00:00
|
|
|
)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
await next(r)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug("React agent processing complete")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.error(f"agent_request Exception: {e}", exc_info=True)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-07-30 23:18:38 +01:00
|
|
|
logger.debug("Send error response...")
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2025-11-26 09:59:10 +00:00
|
|
|
error_obj = Error(
|
|
|
|
|
type = "agent-error",
|
|
|
|
|
message = str(e),
|
2024-11-10 11:44:01 +00:00
|
|
|
)
|
|
|
|
|
|
2025-11-26 09:59:10 +00:00
|
|
|
# Check if streaming was enabled (may not be set if error occurred early)
|
|
|
|
|
streaming = getattr(request, 'streaming', False) if 'request' in locals() else False
|
|
|
|
|
|
|
|
|
|
if streaming:
|
|
|
|
|
# Streaming format
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
chunk_type="error",
|
|
|
|
|
content=str(e),
|
|
|
|
|
end_of_message=True,
|
|
|
|
|
end_of_dialog=True,
|
|
|
|
|
# Legacy fields for backward compatibility
|
|
|
|
|
error=error_obj,
|
|
|
|
|
response=None,
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
# Legacy format
|
|
|
|
|
r = AgentResponse(
|
|
|
|
|
error=error_obj,
|
|
|
|
|
response=None,
|
|
|
|
|
)
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
await respond(r)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def add_args(parser):
|
|
|
|
|
|
2025-04-22 20:21:38 +01:00
|
|
|
AgentService.add_args(parser)
|
2024-11-10 11:44:01 +00:00
|
|
|
|
2024-11-19 21:28:47 +00:00
|
|
|
parser.add_argument(
|
|
|
|
|
'--max-iterations',
|
|
|
|
|
default=default_max_iterations,
|
|
|
|
|
help=f'Maximum number of react iterations (default: {default_max_iterations})',
|
|
|
|
|
)
|
|
|
|
|
|
2025-04-02 16:37:08 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
'--config-type',
|
|
|
|
|
default="agent",
|
|
|
|
|
help=f'Configuration key for prompts (default: agent)',
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-10 11:44:01 +00:00
|
|
|
def run():
|
2025-04-22 20:21:38 +01:00
|
|
|
Processor.launch(default_ident, __doc__)
|
2024-11-10 11:44:01 +00:00
|
|
|
|