Compare commits

...
5 Commits
Author SHA1 Message Date
Mervin Praison 859fb6a263 chore: bump praisonai to v2.2.67 and praisonaiagents to v0.0.138 across all files 2025-07-16 14:16:30 +01:00
Mervin Praison fb2a16126f Merge pull request #952 from MervinPraison/claude/issue-947-20250716-1205
fix: resolve task_name undefined error in LLM callback execution
2025-07-16 14:14:52 +01:00
github-actions[bot]andMervin Praison 318ececfb4 fix: correct function name in test_fix_verification.py
- Fixed unused variable 'results' in test_fix_verification.py
- Maintained test functionality while removing static analysis warning

Co-authored-by: Mervin Praison <[email protected]>
2025-07-16 12:35:26 +00:00
github-actions[bot]andMervin Praison 83afc0891f fix: correct function name in test_fix_verification.py
- Changed register_callback to register_display_callback
- Ensures test runs correctly and validates the fix

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Mervin Praison <[email protected]>
2025-07-16 12:29:42 +00:00
github-actions[bot]andMervin Praison 857238a82a fix: resolve task_name undefined error in LLM callback execution
- Fixed 6 direct execute_sync_callback calls missing task-related parameters
- Added agent_name, agent_role, agent_tools, task_name, task_description, task_id
- Ensures consistent callback parameter passing between verbose and non-verbose modes
- Prevents infinite loop errors when callbacks expect task_name parameter
- Maintains backward compatibility with existing functionality

Fixes #947

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Mervin Praison <[email protected]>
2025-07-16 12:21:27 +00:00
15 changed files with 297 additions and 26 deletions

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
flask \
"praisonai>=2.2.66" \
"praisonai>=2.2.67" \
"praisonai[api]" \
gunicorn \
markdown
+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.2.66" \
"praisonai>=2.2.67" \
"praisonai[chat]" \
"embedchain[github,youtube]"
+1 -1
View File
@@ -20,7 +20,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.2.66" \
"praisonai>=2.2.67" \
"praisonai[ui]" \
"praisonai[chat]" \
"praisonai[realtime]" \
+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.2.66" \
"praisonai>=2.2.67" \
"praisonai[ui]" \
"praisonai[crewai]"
+2 -2
View File
@@ -121,7 +121,7 @@ healthcheck:
## 📦 Package Versions
All Docker images use consistent, up-to-date versions:
- PraisonAI: `>=2.2.66`
- PraisonAI: `>=2.2.67`
- PraisonAI Agents: `>=0.0.92`
- Python: `3.11-slim`
@@ -218,7 +218,7 @@ docker-compose up -d
### Version Pinning
To use specific versions, update the Dockerfile:
```dockerfile
RUN pip install "praisonai==2.2.66" "praisonaiagents==0.0.92"
RUN pip install "praisonai==2.2.67" "praisonaiagents==0.0.92"
```
## 🌐 Production Deployment
@@ -894,7 +894,13 @@ class LLM:
message=original_prompt,
response=response_content,
markdown=markdown,
generation_time=generation_time_val
generation_time=generation_time_val,
agent_name=agent_name,
agent_role=agent_role,
agent_tools=agent_tools,
task_name=task_name,
task_description=task_description,
task_id=task_id
)
callback_executed = True
@@ -963,7 +969,13 @@ class LLM:
message=original_prompt,
response=response_text,
markdown=markdown,
generation_time=time.time() - current_time
generation_time=time.time() - current_time,
agent_name=agent_name,
agent_role=agent_role,
agent_tools=agent_tools,
task_name=task_name,
task_description=task_description,
task_id=task_id
)
callback_executed = True
@@ -1017,7 +1029,13 @@ class LLM:
message=original_prompt,
response=response_text,
markdown=markdown,
generation_time=time.time() - current_time
generation_time=time.time() - current_time,
agent_name=agent_name,
agent_role=agent_role,
agent_tools=agent_tools,
task_name=task_name,
task_description=task_description,
task_id=task_id
)
callback_executed = True
@@ -1175,7 +1193,13 @@ class LLM:
message=original_prompt,
response=response_content,
markdown=markdown,
generation_time=generation_time_val
generation_time=generation_time_val,
agent_name=agent_name,
agent_role=agent_role,
agent_tools=agent_tools,
task_name=task_name,
task_description=task_description,
task_id=task_id
)
callback_executed = True
@@ -1204,7 +1228,13 @@ class LLM:
message=original_prompt,
response=response_text,
markdown=markdown,
generation_time=time.time() - start_time
generation_time=time.time() - start_time,
agent_name=agent_name,
agent_role=agent_role,
agent_tools=agent_tools,
task_name=task_name,
task_description=task_description,
task_id=task_id
)
callback_executed = True
return response_text
@@ -1224,7 +1254,13 @@ class LLM:
message=original_prompt,
response=response_text,
markdown=markdown,
generation_time=time.time() - start_time
generation_time=time.time() - start_time,
agent_name=agent_name,
agent_role=agent_role,
agent_tools=agent_tools,
task_name=task_name,
task_description=task_description,
task_id=task_id
)
callback_executed = True
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "praisonaiagents"
version = "0.0.137"
version = "0.0.138"
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
requires-python = ">=3.10"
authors = [
+1 -1
View File
@@ -2375,7 +2375,7 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.137"
version = "0.0.138"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },
+2 -2
View File
@@ -3,8 +3,8 @@ 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/v2.2.66.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.66.tar.gz | shasum -a 256`.split.first
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.67.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.67.tar.gz | shasum -a 256`.split.first
license "MIT"
depends_on "[email protected]"
+1 -1
View File
@@ -57,7 +57,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.2.66 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==2.2.67 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.2.66"
version = "2.2.67"
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.137",
"praisonaiagents>=0.0.138",
"python-dotenv>=0.19.0",
"instructor>=1.3.3",
"PyYAML>=6.0",
@@ -102,7 +102,7 @@ autogen-v4 = [
[tool.poetry]
name = "PraisonAI"
version = "2.2.66"
version = "2.2.67"
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 = ""
@@ -120,7 +120,7 @@ python = ">=3.10,<3.13"
rich = ">=13.7"
markdown = ">=3.5"
pyparsing = ">=3.0.0"
praisonaiagents = ">=0.0.137"
praisonaiagents = ">=0.0.138"
python-dotenv = ">=0.19.0"
instructor = ">=1.3.3"
PyYAML = ">=6.0"
+5 -5
View File
@@ -4048,7 +4048,7 @@ wheels = [
[[package]]
name = "praisonai"
version = "2.2.66"
version = "2.2.67"
source = { editable = "." }
dependencies = [
{ name = "instructor" },
@@ -4202,7 +4202,7 @@ requires-dist = [
{ name = "praisonai-tools", marker = "extra == 'autogen'", specifier = ">=0.0.22" },
{ name = "praisonai-tools", marker = "extra == 'autogen-v4'", specifier = ">=0.0.22" },
{ name = "praisonai-tools", marker = "extra == 'crewai'", specifier = ">=0.0.22" },
{ name = "praisonaiagents", specifier = ">=0.0.137" },
{ name = "praisonaiagents", specifier = ">=0.0.138" },
{ name = "pyautogen", marker = "extra == 'autogen'", specifier = "==0.2.29" },
{ name = "pydantic", marker = "extra == 'chat'", specifier = "<=2.10.1" },
{ name = "pydantic", marker = "extra == 'code'", specifier = "<=2.10.1" },
@@ -4257,7 +4257,7 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.137"
version = "0.0.138"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "aiohttp" },
@@ -4266,9 +4266,9 @@ dependencies = [
{ name = "pydantic" },
{ name = "rich" },
]
sdist = { url = "https://files.pythonhosted.org/packages/f7/4c/fde4914f2b3285ff2333ffd2e1ea3c5802702f1402036408fe8a4bcfccc0/praisonaiagents-0.0.137.tar.gz", hash = "sha256:79fea894f5737050fcc7b4ad093d0f8e5fc4f7746fee7d6b87d16602cb27ddf5", size = 203856, upload-time = "2025-07-16T13:09:39.537Z" }
sdist = { url = "https://files.pythonhosted.org/packages/04/35/a7bd6bbfb2c6d86026b3fccf72870e7703331894da0587e4dd4d4e45e3d6/praisonaiagents-0.0.138.tar.gz", hash = "sha256:dc3bf46a90021c82f57eb37383dbc37074d6d0131ac5afa2346cea82d72b17f0", size = 203847, upload-time = "2025-07-16T13:15:48.743Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/e7/b8/2464e7e0a9b2fc53cd76c64df779cf16c152c44866567b3263d0d5201eef/praisonaiagents-0.0.137-py3-none-any.whl", hash = "sha256:05552424f4972316e1e76a758eadf041c342e9c1cbb008422d373352cf5f35dc", size = 222976, upload-time = "2025-07-16T13:09:38.043Z" },
{ url = "https://files.pythonhosted.org/packages/84/c7/cf554026d010879d54ba1c1b36c444442165b1e193751c6e2423a665de9d/praisonaiagents-0.0.138-py3-none-any.whl", hash = "sha256:e9da34550b9e432bc866595edee0e4202b920c85ed5f153973b48507a8a2e1be", size = 223071, upload-time = "2025-07-16T13:15:47.44Z" },
]
[[package]]
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""Test the issue fix with a simple callback that expects task_name."""
import asyncio
from praisonaiagents import Agent, Task, PraisonAIAgents
# Simple callback that expects task_name - this would trigger the error before the fix
def test_callback(**kwargs):
print(f"Callback called with task_name: {kwargs.get('task_name', 'NOT PROVIDED')}")
# This would cause the "name 'task_name' is not defined" error before the fix
# because the callback functions would try to access task_name but it wasn't passed
# Register the callback
from praisonaiagents.main import register_display_callback
register_display_callback('interaction', test_callback)
# Example tool
def simple_tool():
return "Simple tool result"
# Simple agent setup
test_agent = Agent(
name="TestAgent",
role="Test Agent",
goal="Test the fix",
tools=[simple_tool],
llm="gpt-4o-mini", # Using OpenAI for testing
verbose=False # This is key - verbose=False triggers the bug
)
# Simple task
test_task = Task(
name="test_task",
description="Test task for the fix",
expected_output="Test output",
agent=test_agent
)
async def main():
print("Testing the fix...")
# This should work without the "name 'task_name' is not defined" error
workflow = PraisonAIAgents(
agents=[test_agent],
tasks=[test_task],
process="sequential",
verbose=False # This should not cause the error anymore
)
try:
await workflow.astart()
print("✅ Test passed! No 'task_name' error occurred.")
return True
except NameError as e:
if "task_name" in str(e):
print(f"❌ Test failed! Still getting task_name error: {e}")
return False
else:
print(f"❌ Test failed with different error: {e}")
return False
except Exception as e:
print(f"⚠️ Test failed with other error (expected without API key): {e}")
# This is expected without API key, but we shouldn't get task_name error
if "task_name" in str(e):
print("❌ But the task_name error is still present!")
return False
else:
print("✅ No task_name error found, fix appears to work!")
return True
if __name__ == "__main__":
asyncio.run(main())
+107
View File
@@ -0,0 +1,107 @@
# agentic_parallelization_varied_tasks.py
import asyncio
from praisonaiagents import Agent, Task, PraisonAIAgents
# Example tools (replace with real implementations as needed)
def fetch_favorite_article():
# Simulate fetching your favorite morning article
return "Your favorite morning article: 'How to Start Your Day Right'"
def search_trending_kenya():
# Simulate searching for trending news in Kenya
return "Trending in Kenya: 'Kenya launches new tech hub in Nairobi'"
def fetch_twitter_feed():
# Simulate fetching Twitter feed
return "Latest tweet: 'AI is transforming the world!'"
# Agents for each unique task
article_agent = Agent(
name="ArticleAgent",
role="Morning Article Fetcher",
goal="Fetch the user's favorite morning article",
tools=[fetch_favorite_article],
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
verbose=True
)
news_agent = Agent(
name="KenyaNewsAgent",
role="Kenya News Searcher",
goal="Search for trending news in Kenya",
tools=[search_trending_kenya],
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
verbose=True
)
twitter_agent = Agent(
name="TwitterAgent",
role="Twitter Feed Fetcher",
goal="Fetch the latest Twitter feed",
tools=[fetch_twitter_feed],
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
verbose=True
)
aggregator = Agent(
name="Aggregator",
role="Result Aggregator",
goal="Aggregate and summarize all results",
llm="gemini/gemini-2.5-flash-lite-preview-06-17",
verbose=True
)
# Tasks for each agent
article_task = Task(
name="fetch_article",
description="Fetch the user's favorite morning article.",
expected_output="The favorite morning article.",
agent=article_agent,
is_start=True,
async_execution=True
)
news_task = Task(
name="search_kenya_news",
description="Search for trending news in Kenya.",
expected_output="Trending news in Kenya.",
agent=news_agent,
is_start=True,
async_execution=True
)
twitter_task = Task(
name="fetch_twitter",
description="Fetch the latest Twitter feed.",
expected_output="Latest Twitter feed.",
agent=twitter_agent,
is_start=True,
async_execution=True
)
# Aggregator task that depends on the above tasks
aggregate_task = Task(
name="aggregate_results",
description="Summarize the article, news, and Twitter feed results.",
expected_output="A summary of all fetched information.",
agent=aggregator,
context=[article_task, news_task, twitter_task]
)
async def main():
workflow = PraisonAIAgents(
agents=[article_agent, news_agent, twitter_agent, aggregator],
tasks=[article_task, news_task, twitter_task, aggregate_task],
process="workflow",
verbose=True
)
results = await workflow.astart()
print("\nParallel Processing Results:")
for task_id, result in results["task_results"].items():
if result:
print(f"Task {task_id}: {result.raw}")
if __name__ == "__main__":
asyncio.run(main())
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
"""Simple test for the task_name fix."""
import sys
from praisonaiagents.main import execute_sync_callback
# Test that execute_sync_callback can handle missing task_name gracefully
def test_callback(message, response, **kwargs):
task_name = kwargs.get('task_name', 'NOT PROVIDED')
print(f"Callback received task_name: {task_name}")
return True
# Register the callback
from praisonaiagents.main import register_display_callback
register_display_callback('interaction', test_callback)
def main():
print("Testing execute_sync_callback with missing task_name...")
# Test the old way (without task_name) - this should work now
try:
execute_sync_callback(
'interaction',
message="test message",
response="test response",
markdown=True,
generation_time=1.0
)
print("✅ Old-style callback works (task_name defaults to None)")
except Exception as e:
print(f"❌ Old-style callback failed: {e}")
return False
# Test the new way (with task_name) - this should also work
try:
execute_sync_callback(
'interaction',
message="test message",
response="test response",
markdown=True,
generation_time=1.0,
task_name="test_task",
task_description="test description",
task_id="test_id"
)
print("✅ New-style callback works (task_name provided)")
except Exception as e:
print(f"❌ New-style callback failed: {e}")
return False
print("✅ All tests passed! The fix is working correctly.")
return True
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)