-
-
Notifications
You must be signed in to change notification settings - Fork 743
Description
Create ReasoningAgent inherited from Agent class, similarly DualBrainAgent.... Interit classes for all of below. rather than the exact example provided below
💡 Proposed PraisonAI Agents Implementation
1. Step-by-Step Reasoning with Configurable Steps
from praisonaiagents import Agent, ReasoningConfig
Simple API with reasoning enabled
agent = Agent(
name="ReasoningAgent",
role="Problem Solver",
reasoning=True, # Enable reasoning
reasoning_config=ReasoningConfig(
min_steps=2,
max_steps=10,
style="analytical" # or "creative", "systematic"
)
)Use directly
response = agent.chat("Solve this complex problem...")
Returns response with reasoning trace
Access reasoning steps
for step in agent.last_reasoning_steps:
print(f"{step.title}: {step.action} (confidence: {step.confidence})")2. Separate Reasoning Models
from praisonaiagents import Agent
Different models for different purposes
agent = Agent(
name="DualBrainAgent",
llm="gpt-4-turbo", # Main conversational model
reasoning_llm="o1-preview", # Analytical reasoning model
reasoning=True
)Or with more control
agent = Agent(
name="SpecialisedAgent",
llm_config={
"model": "gpt-4-turbo",
"temperature": 0.7
},
reasoning_config={
"model": "o1-preview",
"temperature": 0.1,
"system_prompt": "You are a step-by-step analytical reasoner"
}
)3. Confidence Scoring Integration
from praisonaiagents import Agent, Task
Automatic confidence tracking
agent = Agent(
name="ConfidentAgent",
reasoning=True,
min_confidence=0.7 # Retry steps below this threshold
)Task with confidence requirements
task = Task(
description="Calculate the optimal route",
agent=agent,
expected_confidence=0.85, # Task needs 85% confidence
on_low_confidence="retry" # or "escalate", "continue"
)Manual reasoning with confidence
from praisonaiagents.reasoning import reason_step
result = reason_step(
agent=agent,
thought="Breaking down the routing problem",
action="Identify all destinations",
min_confidence=0.8
)4. Action States for Flow Control
from praisonaiagents import Agent, ReasoningFlow
Define reasoning flow with states
agent = Agent(
name="StatefulReasoningAgent",
reasoning=True,
reasoning_flow=ReasoningFlow(
on_validate=lambda step: step.confidence > 0.9,
on_reset=lambda step: step.retries < 3,
auto_validate_critical=True # Validate important steps
)
)Custom task with reasoning states
from praisonaiagents import Task, ActionState
task = Task(
description="Analyse financial data",
agent=agent,
reasoning_states={
ActionState.CONTINUE: "proceed_with_analysis",
ActionState.VALIDATE: "double_check_calculations",
ActionState.FINAL_ANSWER: "generate_report",
ActionState.RESET: "try_alternative_method"
}
)Process with reasoning-aware workflow
from praisonaiagents import Process
process = Process(
agents=[agent],
tasks=[task],
reasoning_mode="collaborative", # Agents reason together
show_reasoning=True # Display reasoning in output
)result = process.run()
print(result.reasoning_trace) # Full reasoning history📋 Implementation Recommendations
1. Minimal Changes Approach
Extend existing Agent class
class Agent:
def init(self, ...existing_params..., reasoning=False, reasoning_config=None):
# Add reasoning capability to existing agent
if reasoning:
self._init_reasoning(reasoning_config)def chat(self, message): if self.reasoning: return self._chat_with_reasoning(message) return self._original_chat(message)2. Leverage Existing Features
Build on existing Chain of Thought tool
from praisonaiagents.tools.train.data.generatecot import ChainOfThoughtGenerator
Wrap existing tool for reasoning
class ReasoningEngine:
def init(self):
self.cot_generator = ChainOfThoughtGenerator()def reason(self, problem, config): # Use existing CoT generation steps = self.cot_generator.generate(problem) return self._format_as_reasoning_steps(steps, config)3. Simple Client Usage
from praisonaiagents import Agent
Basic usage - just add reasoning=True
agent = Agent("Assistant", reasoning=True)
response = agent.chat("Plan a trip to Paris")Advanced usage with full control
agent = Agent(
name="TravelPlanner",
reasoning=True,
reasoning_config={
"min_steps": 3,
"confidence_threshold": 0.8,
"show_internal_thoughts": True
}
)Access reasoning details
response = agent.chat("Plan a trip to Paris")
print(f"Response: {response}")
print(f"Reasoning steps: {len(agent.reasoning_trace)}")
print(f"Final confidence: {agent.reasoning_trace[-1].confidence}")