Compare commits

...
3 Commits
Author SHA1 Message Date
Mervin Praison eca66f9213 feat: bump praisonai to v2.2.76 and praisonaiagents to v0.0.149 with callback refactor 2025-07-25 09:41:04 +01:00
Mervin PraisonandClaude f83f3eae0b fix: ensure consistent display output between OpenAI and Gemini models
- Added execute_sync_callback call in custom LLM path to match OpenAI behavior
- Fixed issue where Gemini/custom LLM responses were not triggering callbacks
- Prevents duplicate display by relying on LLM class to handle verbose display
- Ensures both paths execute callbacks for consistent behavior

The issue was that custom LLM providers (like Gemini) were not calling
_execute_callback_and_display after guardrail validation, while OpenAI
path was. This caused missing Task/Response display boxes for Gemini.

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

Co-Authored-By: Claude <[email protected]>
2025-07-25 08:31:38 +01:00
Mervin Praison 68dd9fb5f1 feat: enable httpx debug logging when LOGLEVEL=debug and remove Ollama handling docs 2025-07-24 10:00:41 +01:00
16 changed files with 100 additions and 57 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.74" \
"praisonai>=2.2.76" \
"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.74" \
"praisonai>=2.2.76" \
"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.74" \
"praisonai>=2.2.76" \
"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.74" \
"praisonai>=2.2.76" \
"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.74`
- PraisonAI: `>=2.2.76`
- 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.74" "praisonaiagents==0.0.92"
RUN pip install "praisonai==2.2.76" "praisonaiagents==0.0.92"
```
## 🌐 Production Deployment
@@ -59,7 +59,7 @@ def _configure_loggers():
# When DEBUG is set, allow some HTTP logging for API endpoints
if loglevel == 'DEBUG':
allowed_debug_loggers = {"httpx._client", "openai._client"}
allowed_debug_loggers = {"httpx", "httpx._client", "openai._client"}
for logger_name in _get_all_noisy_loggers():
if logger_name not in allowed_debug_loggers:
@@ -331,8 +331,15 @@ class Agent:
# Configure logging to suppress unwanted outputs
logging.getLogger("litellm").setLevel(logging.WARNING)
logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)
# Allow httpx logging when LOGLEVEL=debug, otherwise suppress it
loglevel = os.environ.get('LOGLEVEL', 'INFO').upper()
if loglevel == 'DEBUG':
logging.getLogger("httpx").setLevel(logging.INFO)
logging.getLogger("httpcore").setLevel(logging.INFO)
else:
logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)
# If instructions are provided, use them to set role, goal, and backstory
if instructions:
@@ -1229,14 +1236,14 @@ Your Goal: {self.goal}"""
border_style="green",
expand=False
)
else:
# No content yet: show generating message
return Panel(
f"[bold cyan]Generating response...[/bold cyan]",
title=f"[bold]{self.name}[/bold] - {elapsed:.1f}s",
border_style="cyan",
expand=False
)
# else:
# # No content yet: show generating message
# return Panel(
# f"[bold cyan]Generating response...[/bold cyan]",
# title=f"[bold]{self.name}[/bold] - {elapsed:.1f}s",
# border_style="cyan",
# expand=False
# )
def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False, stream=None, task_name=None, task_description=None, task_id=None):
# Reset the final display flag for each new conversation
@@ -1353,6 +1360,8 @@ Your Goal: {self.goal}"""
# Apply guardrail validation for custom LLM response
try:
validated_response = self._apply_guardrail_with_retry(response_text, prompt, temperature, tools, task_name, task_description, task_id)
# Execute callback and display after validation
self._execute_callback_and_display(prompt, validated_response, time.time() - start_time, task_name, task_description, task_id)
return validated_response
except Exception as e:
logging.error(f"Agent {self.name}: Guardrail validation failed for custom LLM: {e}")
@@ -1,25 +0,0 @@
# Ollama Handling in LLM.py
The `ollama_handled` flag is used in `llm.py` (not in `agent.py`) to track whether special Ollama model handling has been applied for tool results. Here's what I found:
## Where it's used in llm.py:
- **Line 863**: `ollama_handled = False` - initialized at the beginning of the tool execution loop
- **Line 864**: Special handling logic via `_handle_ollama_model()` method
- **Line 907**: `ollama_handled = True` - set when Ollama special handling is applied
- **Line 928 & 959**: Checks `if not ollama_handled` to avoid duplicate processing
## Why it's needed:
The flag prevents duplicate processing when Ollama models require special handling. Some Ollama models return only the tool call JSON without processing the results, requiring a follow-up prompt to get the final answer. The `ollama_handled` flag ensures this special handling happens only once.
## Does this contradict the requirement?
**No, it doesn't.** The issue states:
> "ollama/xxxx model is already handled via llm.py via litellm, so no special condition or handling required for ollama inside agent.py"
✅ **Current implementation is correct:**
- `agent.py` has NO ollama-specific conditions (only one documentation mention as an example)
- All ollama handling is contained within `llm.py` as intended
- The `ollama_handled` flag is an internal implementation detail within `llm.py`
The codebase already follows the desired pattern where ollama models are handled through the generic LLM interface via litellm without special conditions in agent.py.
@@ -201,7 +201,14 @@ class LLM:
# These are from external libraries and not useful for debugging user code
logging.getLogger("litellm.utils").setLevel(logging.WARNING)
logging.getLogger("litellm.main").setLevel(logging.WARNING)
logging.getLogger("litellm.llms.custom_httpx.http_handler").setLevel(logging.WARNING)
# Allow httpx logging when LOGLEVEL=debug, otherwise suppress it
loglevel = os.environ.get('LOGLEVEL', 'INFO').upper()
if loglevel == 'DEBUG':
logging.getLogger("litellm.llms.custom_httpx.http_handler").setLevel(logging.INFO)
else:
logging.getLogger("litellm.llms.custom_httpx.http_handler").setLevel(logging.WARNING)
logging.getLogger("litellm.litellm_logging").setLevel(logging.WARNING)
logging.getLogger("litellm.transformation").setLevel(logging.WARNING)
litellm.suppress_debug_messages = True
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "praisonaiagents"
version = "0.0.147"
version = "0.0.149"
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
requires-python = ">=3.10"
authors = [
@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""Test script to compare display output between OpenAI and Gemini models."""
import os
from praisonaiagents import Agent
def test_model_display(model_name, api_key_env=None):
"""Test display output for a specific model."""
print(f"\n{'='*60}")
print(f"Testing {model_name}")
print('='*60)
# Set API key if provided
if api_key_env:
if not os.getenv(api_key_env):
print(f"Skipping {model_name} - {api_key_env} not set")
return
try:
# Create agent with the specified model
agent = Agent(
name=f"{model_name.split('/')[-1]}_agent",
role="Math Assistant",
goal="Help with simple calculations",
backstory="You are a helpful math assistant.",
llm=model_name,
verbose=True, # This should trigger display_interaction
markdown=True
)
# Simple test prompt
response = agent.chat("What is 5 + 3? Please provide a brief answer.")
print(f"\nRaw response: {response}")
except Exception as e:
print(f"Error with {model_name}: {e}")
# Test with different models
if __name__ == "__main__":
print("Testing display output for different LLM models...")
# Test OpenAI
test_model_display("gpt-4o-mini", "OPENAI_API_KEY")
# Test Gemini
test_model_display("gemini/gemini-1.5-flash", "GEMINI_API_KEY")
# Test Anthropic (if available)
test_model_display("claude-3-haiku-20240307", "ANTHROPIC_API_KEY")
print("\n\nTest completed!")
+1 -1
View File
@@ -2422,7 +2422,7 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.147"
version = "0.0.149"
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.74.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.74.tar.gz | shasum -a 256`.split.first
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.76.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.76.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.74 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==2.2.76 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.74"
version = "2.2.76"
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.147",
"praisonaiagents>=0.0.149",
"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.74"
version = "2.2.76"
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.147"
praisonaiagents = ">=0.0.149"
python-dotenv = ">=0.19.0"
instructor = ">=1.3.3"
PyYAML = ">=6.0"
+5 -5
View File
@@ -4031,7 +4031,7 @@ wheels = [
[[package]]
name = "praisonai"
version = "2.2.74"
version = "2.2.76"
source = { editable = "." }
dependencies = [
{ name = "instructor" },
@@ -4185,7 +4185,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.147" },
{ name = "praisonaiagents", specifier = ">=0.0.149" },
{ 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" },
@@ -4240,7 +4240,7 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.147"
version = "0.0.149"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "aiohttp" },
@@ -4249,9 +4249,9 @@ dependencies = [
{ name = "pydantic" },
{ name = "rich" },
]
sdist = { url = "https://files.pythonhosted.org/packages/c7/bd/ed4688ef7290faf76f214e30e3fbdf22276d790588b91968ee71aac635f6/praisonaiagents-0.0.147.tar.gz", hash = "sha256:2c5c8d2fe1cb630218c3f0e9f0dc4c22dffd4f36d113df4d9876484603aef82c", size = 270562, upload-time = "2025-07-24T00:52:45.432Z" }
sdist = { url = "https://files.pythonhosted.org/packages/6e/ec/be31b9a2b40977a993870adfa00dc4cbb54c347e6a689e3f01a9ab4843eb/praisonaiagents-0.0.149.tar.gz", hash = "sha256:2365c1fbc298397713cdb5aafd45fb1f543083274dd9827e589061e89e441b63", size = 270788, upload-time = "2025-07-25T08:39:56.201Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d5/02/88e446fb1232ca586646722e1db4dd94ddf5afc2cd49e6ef9b6b938309a9/praisonaiagents-0.0.147-py3-none-any.whl", hash = "sha256:9e3177346b611b5d3de0820edb16ed9fc8c1ea811f6b6392a9838cd0ade4282b", size = 288525, upload-time = "2025-07-24T00:52:43.845Z" },
{ url = "https://files.pythonhosted.org/packages/e0/08/69bdea25d05d9faa98ea2eaefa63007b46e2092c865d1d5d04e40cd97208/praisonaiagents-0.0.149-py3-none-any.whl", hash = "sha256:bef4d2688759ecbcb84e897f3b3bd701f24672987e0f816829a6f1be74be29fa", size = 288759, upload-time = "2025-07-25T08:39:54.598Z" },
]
[[package]]