Compare commits

..
2 Commits
Author SHA1 Message Date
Mervin Praison 56a42e6d95 Merge pull request #292 from MervinPraison/develop
Update PraisonAI and praisonaiagents to version 2.0.45 and 0.0.35 res…
2025-01-13 11:49:53 +00:00
MervinPraison d2b4affdd1 Update PraisonAI and praisonaiagents to version 2.0.45 and 0.0.35 respectively
- Bumped the PraisonAI package version from 2.0.44 to 2.0.45 in Dockerfile, pyproject.toml, and related files.
- Updated the installation command in Dockerfile and deployment scripts to reflect the new version.
- Updated the praisonaiagents package version from 0.0.34 to 0.0.35 in relevant files.
- Introduced new evaluator-optimiser and parallelisation features with corresponding agent and task implementations.
- Added documentation for the evaluator-optimiser feature and updated existing documentation for parallelisation.
- Adjusted dependencies in uv.lock for compatibility with the new versions.
2025-01-13 11:49:32 +00:00
15 changed files with 346 additions and 24 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install flask praisonai==2.0.44 gunicorn markdown
RUN pip install flask praisonai==2.0.45 gunicorn markdown
EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
@@ -5,21 +5,33 @@ generator = Agent(
name="Generator",
role="Solution generator",
goal="Generate initial solutions and incorporate feedback",
instructions="Generate solutions and refine based on evaluator feedback"
instructions=(
"1. Look at the context from previous tasks.\n"
"2. If you see that you have already produced 2 points, then add another 2 new points "
" so that the total becomes 10.\n"
"3. Otherwise, just produce the first 2 points.\n"
"4. Return only the final list of points, with no extra explanation."
)
)
evaluator = Agent(
name="Evaluator",
role="Solution evaluator",
goal="Evaluate solutions and provide improvement feedback",
instructions="Evaluate solutions for accuracy and provide specific feedback for improvements"
instructions=(
"1. Count how many lines in the response start with a number and a period (like '1. ' or '2. ').\n"
"2. If there are 10 or more, respond with 'done'.\n"
"3. Otherwise, respond with 'more'.\n"
"4. Return only the single word: 'done' or 'more'."
)
)
# Create tasks for the feedback loop
generate_task = Task(
name="generate",
description="Write 5 points about AI",
expected_output="5 points",
description="Write 2 points about AI incuding if anything exiting from previous points",
expected_output="2 points",
agent=generator,
is_start=True,
task_type="decision",
File renamed without changes.
+26 -3
View File
@@ -10,14 +10,16 @@ class LoopItems(BaseModel):
items: List[Any]
class Process:
def __init__(self, tasks: Dict[str, Task], agents: List[Agent], manager_llm: Optional[str] = None, verbose: bool = False):
def __init__(self, tasks: Dict[str, Task], agents: List[Agent], manager_llm: Optional[str] = None, verbose: bool = False, max_iter: int = 10):
self.tasks = tasks
self.agents = agents
self.manager_llm = manager_llm
self.verbose = verbose
self.max_iter = max_iter
async def aworkflow(self) -> AsyncGenerator[str, None]:
"""Async version of workflow method"""
current_iter = 0 # Track how many times we've looped
# Build workflow relationships first
for task in self.tasks.values():
if task.next_tasks:
@@ -41,7 +43,12 @@ class Process:
visited_tasks = set()
loop_data = {} # Store loop-specific data
while current_task and current_task.id not in visited_tasks:
while current_task:
current_iter += 1
if current_iter > self.max_iter:
logging.info(f"Max iteration limit {self.max_iter} reached, ending workflow.")
break
task_id = current_task.id
logging.info(f"Executing workflow task: {current_task.name if current_task.name else task_id}")
@@ -111,6 +118,11 @@ Return a JSON object with an 'items' array containing the items to process.
yield task_id
visited_tasks.add(task_id)
# Reset completed task to "not started" so it can run again
if self.tasks[task_id].status == "completed":
logging.debug(f"Task {task_id} was completed, resetting to 'not started' for next iteration.")
self.tasks[task_id].status = "not started"
# Handle loop progression
if current_task.task_type == "loop":
loop_key = f"loop_{current_task.name}"
@@ -291,6 +303,7 @@ Provide a JSON with the structure:
def workflow(self):
"""Synchronous version of workflow method"""
current_iter = 0 # Track how many times we've looped
# Build workflow relationships first
for task in self.tasks.values():
if task.next_tasks:
@@ -314,7 +327,12 @@ Provide a JSON with the structure:
visited_tasks = set()
loop_data = {} # Store loop-specific data
while current_task and current_task.id not in visited_tasks:
while current_task:
current_iter += 1
if current_iter > self.max_iter:
logging.info(f"Max iteration limit {self.max_iter} reached, ending workflow.")
break
task_id = current_task.id
logging.info(f"Executing workflow task: {current_task.name if current_task.name else task_id}")
@@ -378,6 +396,11 @@ Return a JSON object with an 'items' array containing the items to process.
yield task_id
visited_tasks.add(task_id)
# Reset completed task to "not started" so it can run again
if self.tasks[task_id].status == "completed":
logging.debug(f"Task {task_id} was completed, resetting to 'not started' for next iteration.")
self.tasks[task_id].status = "not started"
# Handle loop progression
if current_task.task_type == "loop":
loop_key = f"loop_{current_task.name}"
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "praisonaiagents"
version = "0.0.34"
version = "0.0.35"
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
authors = [
{ name="Mervin Praison" }
+1 -1
View File
@@ -990,7 +990,7 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.34"
version = "0.0.35"
source = { editable = "." }
dependencies = [
{ name = "openai" },
+70
View File
@@ -0,0 +1,70 @@
from praisonaiagents import Agent, Task, PraisonAIAgents
# Create generator and evaluator agents
generator = Agent(
name="Generator",
role="Solution generator",
goal="Generate initial solutions and incorporate feedback",
instructions=(
"1. Look at the context from previous tasks.\n"
"2. If you see that you have already produced 2 points, then add another 2 new points "
" so that the total becomes 10.\n"
"3. Otherwise, just produce the first 2 points.\n"
"4. Return only the final list of points, with no extra explanation."
)
)
evaluator = Agent(
name="Evaluator",
role="Solution evaluator",
goal="Evaluate solutions and provide improvement feedback",
instructions=(
"1. Count how many lines in the response start with a number and a period (like '1. ' or '2. ').\n"
"2. If there are 10 or more, respond with 'done'.\n"
"3. Otherwise, respond with 'more'.\n"
"4. Return only the single word: 'done' or 'more'."
)
)
# Create tasks for the feedback loop
generate_task = Task(
name="generate",
description="Write 2 points about AI incuding if anything exiting from previous points",
expected_output="2 points",
agent=generator,
is_start=True,
task_type="decision",
next_tasks=["evaluate"]
)
evaluate_task = Task(
name="evaluate",
description="Check if there are 10 points about AI",
expected_output="more or done",
agent=evaluator,
next_tasks=["generate"],
context=[generate_task],
task_type="decision",
condition={
"more": ["generate"], # Continue to generate
"done": [""] # Exit when optimization complete
}
)
# Create workflow manager
workflow = PraisonAIAgents(
agents=[generator, evaluator],
tasks=[generate_task, evaluate_task],
process="workflow",
verbose=True
)
# Run optimization workflow
results = workflow.start()
# Print results
print("\nEvaluator-Optimizer Results:")
for task_id, result in results["task_results"].items():
if result:
print(f"Task {task_id}: {result.raw}")
+1 -1
View File
@@ -110,7 +110,7 @@ Loads environment variables from .env file or system and sets them.</p>
file.write(&#34;FROM python:3.11-slim\n&#34;)
file.write(&#34;WORKDIR /app\n&#34;)
file.write(&#34;COPY . .\n&#34;)
file.write(&#34;RUN pip install flask praisonai==2.0.44 gunicorn markdown\n&#34;)
file.write(&#34;RUN pip install flask praisonai==2.0.45 gunicorn markdown\n&#34;)
file.write(&#34;EXPOSE 8080\n&#34;)
file.write(&#39;CMD [&#34;gunicorn&#34;, &#34;-b&#34;, &#34;0.0.0.0:8080&#34;, &#34;api:app&#34;]\n&#39;)
+216
View File
@@ -0,0 +1,216 @@
---
title: "Agentic Evaluator Optimiser Workflow"
sidebarTitle: "Evaluator Optimiser"
description: "Learn how to create AI agents that can generate and optimize solutions through iterative feedback."
icon: "arrows-rotate"
---
## Quick Start
<Steps>
<Step title="Install Package">
First, install the PraisonAI Agents package:
```bash
pip install praisonaiagents
```
</Step>
<Step title="Set API Key">
Set your OpenAI API key as an environment variable in your terminal:
```bash
export OPENAI_API_KEY=your_api_key_here
```
</Step>
<Step title="Create a file">
Create a new file `app.py` with the basic setup:
```python
from praisonaiagents import Agent, Task, PraisonAIAgents
# Create generator and evaluator agents
generator = Agent(
name="Generator",
role="Solution generator",
goal="Generate initial solutions and incorporate feedback",
instructions=(
"1. Look at the context from previous tasks.\n"
"2. If you see that you have already produced 2 points, then add another 2 new points "
" so that the total becomes 10.\n"
"3. Otherwise, just produce the first 2 points.\n"
"4. Return only the final list of points, with no extra explanation."
)
)
evaluator = Agent(
name="Evaluator",
role="Solution evaluator",
goal="Evaluate solutions and provide improvement feedback",
instructions=(
"1. Count how many lines in the response start with a number and a period (like '1. ' or '2. ').\n"
"2. If there are 10 or more, respond with 'done'.\n"
"3. Otherwise, respond with 'more'.\n"
"4. Return only the single word: 'done' or 'more'."
)
)
# Create tasks for the feedback loop
generate_task = Task(
name="generate",
description="Write 2 points about AI incuding if anything exiting from previous points",
expected_output="2 points",
agent=generator,
is_start=True,
task_type="decision",
next_tasks=["evaluate"]
)
evaluate_task = Task(
name="evaluate",
description="Check if there are 10 points about AI",
expected_output="more or done",
agent=evaluator,
next_tasks=["generate"],
context=[generate_task],
task_type="decision",
condition={
"more": ["generate"], # Continue to generate
"done": [""] # Exit when optimization complete
}
)
# Create workflow manager
workflow = PraisonAIAgents(
agents=[generator, evaluator],
tasks=[generate_task, evaluate_task],
process="workflow",
verbose=True
)
# Run optimization workflow
results = workflow.start()
# Print results
print("\nEvaluator-Optimizer Results:")
for task_id, result in results["task_results"].items():
if result:
print(f"Task {task_id}: {result.raw}")
```
</Step>
<Step title="Start Agents">
Type this in your terminal to run your agents:
```bash
python app.py
```
</Step>
</Steps>
<Note>
**Requirements**
- Python 3.10 or higher
- OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys). Use Other models using [this guide](/models).
- Basic understanding of Python
</Note>
## Understanding Evaluator-Optimizer
<Card title="What is Evaluator-Optimizer?" icon="question">
Evaluator-Optimizer pattern enables:
- Iterative solution generation and refinement
- Automated quality evaluation
- Feedback-driven optimization
- Continuous improvement loops
</Card>
## Features
<CardGroup cols={2}>
<Card title="Solution Generation" icon="wand-magic-sparkles">
Generate solutions based on requirements and feedback.
</Card>
<Card title="Quality Evaluation" icon="magnifying-glass-chart">
Automatically assess solution quality and completeness.
</Card>
<Card title="Feedback Loop" icon="rotate">
Implement iterative improvement through feedback cycles.
</Card>
<Card title="Process Control" icon="sliders">
Monitor and control the optimization process.
</Card>
</CardGroup>
## Configuration Options
```python
# Create a generator agent
generator = Agent(
name="Generator",
role="Solution generator",
goal="Generate and improve solutions",
instructions="Step-by-step instructions for generation",
verbose=True # Enable detailed logging
)
# Create an evaluator agent
evaluator = Agent(
name="Evaluator",
role="Solution evaluator",
goal="Evaluate and provide feedback",
instructions="Evaluation criteria and feedback format"
)
# Create tasks with feedback loop
generate_task = Task(
name="generate",
description="Generate solution",
agent=generator,
is_start=True,
task_type="decision",
next_tasks=["evaluate"]
)
evaluate_task = Task(
name="evaluate",
description="Evaluate solution",
agent=evaluator,
context=[generate_task],
task_type="decision",
condition={
"more": ["generate"], # Continue optimization
"done": [""] # Exit when complete
}
)
```
## Troubleshooting
<CardGroup cols={2}>
<Card title="Generation Issues" icon="triangle-exclamation">
If generation is not improving:
- Review generator instructions
- Check feedback integration
- Enable verbose mode for debugging
</Card>
<Card title="Evaluation Flow" icon="diagram-project">
If evaluation cycle is incorrect:
- Verify evaluation criteria
- Check condition mappings
- Review feedback loop connections
</Card>
</CardGroup>
## Next Steps
<CardGroup cols={2}>
<Card title="AutoAgents" icon="robot" href="./autoagents">
Learn about automatically created and managed AI agents
</Card>
<Card title="Mini Agents" icon="microchip" href="./mini">
Explore lightweight, focused AI agents
</Card>
</CardGroup>
<Note>
For optimal results, ensure your generator instructions and evaluation criteria are clear and well-defined to achieve the desired optimization outcomes.
</Note>
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: "Parallelisation"
title: "Agentic Parallelisation"
description: "Learn how to create AI agents that can execute tasks in parallel for improved performance."
icon: "arrows-split-up-and-left"
---
+2 -1
View File
@@ -93,7 +93,8 @@
"features/callbacks",
"features/agenticrouting",
"features/promptchaining",
"features/parallelisation"
"features/parallelisation",
"features/evaluator-optimiser"
]
},
{
+1 -1
View File
@@ -3,7 +3,7 @@ class Praisonai < Formula
desc "AI tools for various AI applications"
homepage "https://github.com/MervinPraison/PraisonAI"
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.44.tar.gz"
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.45.tar.gz"
sha256 "1828fb9227d10f991522c3f24f061943a254b667196b40b1a3e4a54a8d30ce32" # Replace with actual SHA256 checksum
license "MIT"
+1 -1
View File
@@ -56,7 +56,7 @@ class CloudDeployer:
file.write("FROM python:3.11-slim\n")
file.write("WORKDIR /app\n")
file.write("COPY . .\n")
file.write("RUN pip install flask praisonai==2.0.44 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==2.0.45 gunicorn markdown\n")
file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
+4 -4
View File
@@ -1,6 +1,6 @@
[project]
name = "PraisonAI"
version = "2.0.44"
version = "2.0.45"
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human–agent collaboration."
readme = "README.md"
license = ""
@@ -12,7 +12,7 @@ dependencies = [
"rich>=13.7",
"markdown>=3.5",
"pyparsing>=3.0.0",
"praisonaiagents>=0.0.34",
"praisonaiagents>=0.0.35",
"python-dotenv>=0.19.0",
"instructor>=1.3.3",
"PyYAML>=6.0",
@@ -84,7 +84,7 @@ autogen = ["pyautogen>=0.2.19", "praisonai-tools>=0.0.7", "crewai"]
[tool.poetry]
name = "PraisonAI"
version = "2.0.44"
version = "2.0.45"
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human–agent collaboration."
authors = ["Mervin Praison"]
license = ""
@@ -102,7 +102,7 @@ python = ">=3.10,<3.13"
rich = ">=13.7"
markdown = ">=3.5"
pyparsing = ">=3.0.0"
praisonaiagents = ">=0.0.34"
praisonaiagents = ">=0.0.35"
python-dotenv = ">=0.19.0"
instructor = ">=1.3.3"
PyYAML = ">=6.0"
Generated
+5 -5
View File
@@ -3060,7 +3060,7 @@ wheels = [
[[package]]
name = "praisonai"
version = "2.0.44"
version = "2.0.45"
source = { editable = "." }
dependencies = [
{ name = "instructor" },
@@ -3197,7 +3197,7 @@ requires-dist = [
{ name = "plotly", marker = "extra == 'realtime'", specifier = ">=5.24.0" },
{ name = "praisonai-tools", marker = "extra == 'autogen'", specifier = ">=0.0.7" },
{ name = "praisonai-tools", marker = "extra == 'crewai'", specifier = ">=0.0.7" },
{ name = "praisonaiagents", specifier = ">=0.0.34" },
{ name = "praisonaiagents", specifier = ">=0.0.35" },
{ name = "pyautogen", marker = "extra == 'autogen'", specifier = ">=0.2.19" },
{ name = "pydantic", marker = "extra == 'chat'", specifier = "<=2.10.1" },
{ name = "pydantic", marker = "extra == 'code'", specifier = "<=2.10.1" },
@@ -3250,16 +3250,16 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.34"
version = "0.0.35"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "openai" },
{ name = "pydantic" },
{ name = "rich" },
]
sdist = { url = "https://files.pythonhosted.org/packages/cc/98/00ef0d9d50a810f38710647fe2dd6c198b084b787eae5e43307de1b6118b/praisonaiagents-0.0.34.tar.gz", hash = "sha256:1e6e3c37145a1a62030151d014f4f399d9d08a77ee0fd14bcf49f0482bd041fb", size = 69170 }
sdist = { url = "https://files.pythonhosted.org/packages/58/2e/f7899ee05c74b0f2ddd237490f361865b85be404f7888c6229e5292a9af4/praisonaiagents-0.0.35.tar.gz", hash = "sha256:23fdda1320f29cdc86162a8a0b8e77bad07ad793a2f08d6d8d7f7729a01f7ab7", size = 69306 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/19/4c/dbb750a2156753ceff051f5ac7b6bba284d1fc57fc9a1aa7fded855009e5/praisonaiagents-0.0.34-py3-none-any.whl", hash = "sha256:a895ee63c73f129d9fa33bbdbe4f13bc5de50509c5565247f640141ef4b8aa8c", size = 85896 },
{ url = "https://files.pythonhosted.org/packages/d2/11/678bfe9b57d8d0a3b0f5f01c2cdb52d12ed6dcd157cc6324b084f265ba1b/praisonaiagents-0.0.35-py3-none-any.whl", hash = "sha256:0c0f9650cb67449261738cd7225d5815434bc042cca319e7e7230196b47807cf", size = 86057 },
]
[[package]]