mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 17:33:33 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18b85aada0 | ||
|
|
a3c77692fd | ||
|
|
4a06ee3626 | ||
|
|
776e83100e | ||
|
|
f718d89ba4 | ||
|
|
3469335d02 | ||
|
|
6caa825706 | ||
|
|
65a23df7a2 |
No files matched your search
+1
-1
@@ -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.79" \
|
||||
"praisonai>=2.2.80" \
|
||||
"praisonai[api]" \
|
||||
gunicorn \
|
||||
markdown
|
||||
|
||||
@@ -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.79" \
|
||||
"praisonai>=2.2.80" \
|
||||
"praisonai[chat]" \
|
||||
"embedchain[github,youtube]"
|
||||
|
||||
|
||||
@@ -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.79" \
|
||||
"praisonai>=2.2.80" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[chat]" \
|
||||
"praisonai[realtime]" \
|
||||
|
||||
@@ -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.79" \
|
||||
"praisonai>=2.2.80" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[crewai]"
|
||||
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ healthcheck:
|
||||
## 📦 Package Versions
|
||||
|
||||
All Docker images use consistent, up-to-date versions:
|
||||
- PraisonAI: `>=2.2.79`
|
||||
- PraisonAI: `>=2.2.80`
|
||||
- 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.79" "praisonaiagents==0.0.92"
|
||||
RUN pip install "praisonai==2.2.80" "praisonaiagents==0.0.92"
|
||||
```
|
||||
|
||||
## 🌐 Production Deployment
|
||||
|
||||
File renamed without changes.
@@ -383,6 +383,7 @@ class Agent:
|
||||
llm_config['base_url'] = base_url
|
||||
if api_key:
|
||||
llm_config['api_key'] = api_key
|
||||
llm_config['metrics'] = metrics
|
||||
self.llm_instance = LLM(**llm_config)
|
||||
else:
|
||||
# Create LLM with model string and base_url
|
||||
@@ -390,7 +391,8 @@ class Agent:
|
||||
self.llm_instance = LLM(
|
||||
model=model_name,
|
||||
base_url=base_url,
|
||||
api_key=api_key
|
||||
api_key=api_key,
|
||||
metrics=metrics
|
||||
)
|
||||
self._using_custom_llm = True
|
||||
except ImportError as e:
|
||||
@@ -406,6 +408,9 @@ class Agent:
|
||||
if api_key and 'api_key' not in llm:
|
||||
llm = llm.copy()
|
||||
llm['api_key'] = api_key
|
||||
# Add metrics parameter
|
||||
llm = llm.copy()
|
||||
llm['metrics'] = metrics
|
||||
self.llm_instance = LLM(**llm) # Pass all dict items as kwargs
|
||||
self._using_custom_llm = True
|
||||
except ImportError as e:
|
||||
@@ -421,6 +426,7 @@ class Agent:
|
||||
llm_params = {'model': llm}
|
||||
if api_key:
|
||||
llm_params['api_key'] = api_key
|
||||
llm_params['metrics'] = metrics
|
||||
self.llm_instance = LLM(**llm_params)
|
||||
self._using_custom_llm = True
|
||||
|
||||
|
||||
@@ -260,6 +260,7 @@ class LLM:
|
||||
self.max_reflect = extra_settings.get('max_reflect', 3)
|
||||
self.min_reflect = extra_settings.get('min_reflect', 1)
|
||||
self.reasoning_steps = extra_settings.get('reasoning_steps', False)
|
||||
self.metrics = extra_settings.get('metrics', False)
|
||||
|
||||
# Token tracking
|
||||
self.last_token_metrics: Optional[TokenMetrics] = None
|
||||
@@ -954,7 +955,8 @@ class LLM:
|
||||
final_response = resp
|
||||
|
||||
# Track token usage
|
||||
self._track_token_usage(final_response, model)
|
||||
if self.metrics:
|
||||
self._track_token_usage(final_response, model)
|
||||
|
||||
# Execute callbacks and display based on verbose setting
|
||||
generation_time_val = time.time() - current_time
|
||||
@@ -1135,7 +1137,8 @@ class LLM:
|
||||
response_text = response_content if response_content is not None else ""
|
||||
|
||||
# Track token usage
|
||||
self._track_token_usage(final_response, self.model)
|
||||
if self.metrics:
|
||||
self._track_token_usage(final_response, self.model)
|
||||
|
||||
# Execute callbacks and display based on verbose setting
|
||||
if verbose and not interaction_displayed:
|
||||
@@ -1284,7 +1287,8 @@ class LLM:
|
||||
response_text = response_content if response_content is not None else ""
|
||||
|
||||
# Track token usage
|
||||
self._track_token_usage(final_response, self.model)
|
||||
if self.metrics:
|
||||
self._track_token_usage(final_response, self.model)
|
||||
|
||||
# Execute callbacks and display based on verbose setting
|
||||
if verbose and not interaction_displayed:
|
||||
@@ -2887,6 +2891,9 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
|
||||
if not TokenMetrics or not _token_collector:
|
||||
return None
|
||||
|
||||
# Note: metrics check moved to call sites for performance
|
||||
# This method should only be called when self.metrics=True
|
||||
|
||||
try:
|
||||
usage = response.get("usage", {})
|
||||
if not usage:
|
||||
|
||||
@@ -5,12 +5,14 @@ over HTTP Stream transport, implementing the Streamable HTTP transport protocol.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import atexit
|
||||
import logging
|
||||
import threading
|
||||
import inspect
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
import weakref
|
||||
from typing import List, Dict, Any, Optional, Callable, Iterable, Union
|
||||
from urllib.parse import urlparse, urljoin
|
||||
|
||||
@@ -25,6 +27,10 @@ logger = logging.getLogger("mcp-http-stream")
|
||||
# Global event loop for async operations
|
||||
_event_loop = None
|
||||
|
||||
# Global registry of active clients for cleanup
|
||||
_active_clients = weakref.WeakSet()
|
||||
_cleanup_registered = False
|
||||
|
||||
def get_event_loop():
|
||||
"""Get or create a global event loop."""
|
||||
global _event_loop
|
||||
@@ -34,6 +40,31 @@ def get_event_loop():
|
||||
return _event_loop
|
||||
|
||||
|
||||
def _cleanup_all_clients():
|
||||
"""Clean up all active clients at program exit."""
|
||||
if not _active_clients:
|
||||
return
|
||||
|
||||
# Create a copy to avoid modification during iteration
|
||||
clients_to_cleanup = list(_active_clients)
|
||||
|
||||
for client in clients_to_cleanup:
|
||||
try:
|
||||
if hasattr(client, '_force_cleanup'):
|
||||
client._force_cleanup()
|
||||
except Exception:
|
||||
# Ignore exceptions during cleanup
|
||||
pass
|
||||
|
||||
|
||||
def _register_cleanup():
|
||||
"""Register the cleanup function to run at program exit."""
|
||||
global _cleanup_registered
|
||||
if not _cleanup_registered:
|
||||
atexit.register(_cleanup_all_clients)
|
||||
_cleanup_registered = True
|
||||
|
||||
|
||||
class HTTPStreamMCPTool:
|
||||
"""A wrapper for an MCP tool that can be used with praisonaiagents."""
|
||||
|
||||
@@ -388,6 +419,7 @@ class HTTPStreamMCPClient:
|
||||
self.session = None
|
||||
self.tools = []
|
||||
self.transport = None
|
||||
self._closed = False
|
||||
|
||||
# Set up logging
|
||||
if debug:
|
||||
@@ -396,6 +428,10 @@ class HTTPStreamMCPClient:
|
||||
# Set to WARNING by default to hide INFO messages
|
||||
logger.setLevel(logging.WARNING)
|
||||
|
||||
# Register this client for cleanup and setup exit handler
|
||||
_active_clients.add(self)
|
||||
_register_cleanup()
|
||||
|
||||
self._initialize()
|
||||
|
||||
def _initialize(self):
|
||||
@@ -456,6 +492,10 @@ class HTTPStreamMCPClient:
|
||||
timeout=self.timeout
|
||||
)
|
||||
tools.append(wrapper)
|
||||
|
||||
# Set up cleanup finalizer now that transport and session are created
|
||||
self._finalizer = weakref.finalize(self, self._static_cleanup,
|
||||
self.transport, self._session_context)
|
||||
|
||||
return tools
|
||||
|
||||
@@ -477,30 +517,97 @@ class HTTPStreamMCPClient:
|
||||
|
||||
async def aclose(self):
|
||||
"""Async cleanup method to close all resources."""
|
||||
if self.transport:
|
||||
await self.transport.__aexit__(None, None, None)
|
||||
if hasattr(self, '_session_context') and self._session_context:
|
||||
await self._session_context.__aexit__(None, None, None)
|
||||
if self._closed:
|
||||
return
|
||||
|
||||
self._closed = True
|
||||
|
||||
try:
|
||||
if hasattr(self, '_session_context') and self._session_context:
|
||||
await self._session_context.__aexit__(None, None, None)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
if self.transport:
|
||||
await self.transport.__aexit__(None, None, None)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
"""Synchronous cleanup method to close all resources."""
|
||||
if hasattr(self, 'transport') and self.transport and not getattr(self.transport, '_closed', False):
|
||||
try:
|
||||
# Use the global event loop for non-blocking cleanup
|
||||
loop = get_event_loop()
|
||||
if not loop.is_closed():
|
||||
# Schedule cleanup without blocking
|
||||
asyncio.run_coroutine_threadsafe(self.aclose(), loop)
|
||||
except Exception:
|
||||
# Silently ignore cleanup errors to avoid impacting performance
|
||||
pass
|
||||
if self._closed:
|
||||
return
|
||||
|
||||
try:
|
||||
# Use the global event loop for non-blocking cleanup
|
||||
loop = get_event_loop()
|
||||
if not loop.is_closed():
|
||||
# Schedule cleanup without blocking - add callback for fallback
|
||||
future = asyncio.run_coroutine_threadsafe(self.aclose(), loop)
|
||||
|
||||
# Add a completion callback for fallback cleanup if async fails
|
||||
def _cleanup_callback(fut):
|
||||
try:
|
||||
fut.result() # This will raise if aclose() failed
|
||||
except Exception:
|
||||
# If async cleanup failed, try force cleanup
|
||||
try:
|
||||
self._force_cleanup()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
future.add_done_callback(_cleanup_callback)
|
||||
else:
|
||||
# Event loop is closed, use force cleanup immediately
|
||||
self._force_cleanup()
|
||||
except Exception:
|
||||
# If async scheduling fails, try force cleanup
|
||||
self._force_cleanup()
|
||||
|
||||
def _force_cleanup(self):
|
||||
"""Force cleanup of resources synchronously (for emergencies)."""
|
||||
if self._closed:
|
||||
return
|
||||
|
||||
self._closed = True
|
||||
|
||||
# Force close transport session if it exists
|
||||
try:
|
||||
if self.transport and hasattr(self.transport, '_session') and self.transport._session:
|
||||
session = self.transport._session
|
||||
if not session.closed:
|
||||
# Force close the aiohttp session
|
||||
if hasattr(session, '_connector') and session._connector:
|
||||
try:
|
||||
# Close connector directly
|
||||
session._connector.close()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def _static_cleanup(transport, session_context):
|
||||
"""Static cleanup method for weakref finalizer."""
|
||||
try:
|
||||
# This is called by weakref finalizer, so we can't do async operations
|
||||
# Just ensure any session is closed if possible
|
||||
if transport and hasattr(transport, '_session') and transport._session:
|
||||
session = transport._session
|
||||
if not session.closed and hasattr(session, '_connector'):
|
||||
try:
|
||||
session._connector.close()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def __del__(self):
|
||||
"""Cleanup when object is garbage collected."""
|
||||
try:
|
||||
# Simple, lightweight cleanup
|
||||
if hasattr(self, 'transport') and self.transport:
|
||||
self.close()
|
||||
if not self._closed:
|
||||
self._force_cleanup()
|
||||
except Exception:
|
||||
# Never raise exceptions in __del__
|
||||
pass
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "praisonaiagents"
|
||||
version = "0.0.153"
|
||||
version = "0.0.154"
|
||||
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
|
||||
requires-python = ">=3.10"
|
||||
authors = [
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple verification test for the performance optimization.
|
||||
Tests that metrics check happens at call sites, not inside the method.
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
class MockLLM:
|
||||
"""Mock LLM class to test the optimization pattern."""
|
||||
|
||||
def __init__(self, metrics=False):
|
||||
self.metrics = metrics
|
||||
self.call_count = 0
|
||||
|
||||
def _track_token_usage(self, response, model):
|
||||
"""Mock method that increments call count."""
|
||||
self.call_count += 1
|
||||
return None
|
||||
|
||||
def process_response_optimized(self, response, model):
|
||||
"""Optimized version: check metrics before calling method."""
|
||||
if self.metrics:
|
||||
self._track_token_usage(response, model)
|
||||
|
||||
def process_response_unoptimized(self, response, model):
|
||||
"""Unoptimized version: always call method, check inside."""
|
||||
self._track_token_usage(response, model)
|
||||
# Note: In real implementation, method would return early if not self.metrics
|
||||
|
||||
def test_optimization():
|
||||
"""Test that optimization reduces method calls when metrics disabled."""
|
||||
|
||||
print("🔧 Testing performance optimization...")
|
||||
|
||||
# Test optimized version
|
||||
llm_optimized = MockLLM(metrics=False)
|
||||
|
||||
# Process 100 responses
|
||||
for i in range(100):
|
||||
llm_optimized.process_response_optimized({}, "test-model")
|
||||
|
||||
print(f"✅ Optimized version (metrics=False): {llm_optimized.call_count} method calls")
|
||||
|
||||
# Test unoptimized version
|
||||
llm_unoptimized = MockLLM(metrics=False)
|
||||
|
||||
for i in range(100):
|
||||
llm_unoptimized.process_response_unoptimized({}, "test-model")
|
||||
|
||||
print(f"❌ Unoptimized version (metrics=False): {llm_unoptimized.call_count} method calls")
|
||||
|
||||
# Verify optimization works
|
||||
if llm_optimized.call_count == 0:
|
||||
print("✅ SUCCESS: Zero method calls when metrics=False (optimal)")
|
||||
else:
|
||||
print("❌ FAILED: Method still called when metrics=False")
|
||||
|
||||
if llm_unoptimized.call_count == 100:
|
||||
print("✅ Confirmed: Unoptimized version calls method unnecessarily")
|
||||
|
||||
# Test that metrics=True still works
|
||||
llm_enabled = MockLLM(metrics=True)
|
||||
|
||||
for i in range(10):
|
||||
llm_enabled.process_response_optimized({}, "test-model")
|
||||
|
||||
if llm_enabled.call_count == 10:
|
||||
print("✅ SUCCESS: Method called correctly when metrics=True")
|
||||
else:
|
||||
print("❌ FAILED: Method not called when metrics=True")
|
||||
|
||||
print("\n🎯 Optimization verification complete!")
|
||||
|
||||
return llm_optimized.call_count == 0 and llm_enabled.call_count == 10
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_optimization()
|
||||
if success:
|
||||
print("🚀 All tests passed! Optimization is working correctly.")
|
||||
else:
|
||||
print("⚠️ Some tests failed. Review implementation.")
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Performance test to verify that metrics=False has zero overhead.
|
||||
Tests the optimized implementation where metrics checks happen at call sites.
|
||||
"""
|
||||
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add the source path
|
||||
sys.path.insert(0, '/home/runner/work/PraisonAI/PraisonAI/src/praisonai-agents')
|
||||
|
||||
def test_performance_impact():
|
||||
"""Test if metrics=False has any performance overhead."""
|
||||
|
||||
print("🚀 Testing performance impact of metrics implementation...")
|
||||
|
||||
# Mock response object similar to what LiteLLM returns
|
||||
mock_response = {
|
||||
"usage": {
|
||||
"prompt_tokens": 100,
|
||||
"completion_tokens": 50,
|
||||
"total_tokens": 150
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
from praisonaiagents.llm.llm import LLM
|
||||
|
||||
# Test with metrics disabled (default case)
|
||||
print("\n📊 Testing with metrics=False (default)...")
|
||||
llm_no_metrics = LLM(model="test-model", metrics=False)
|
||||
|
||||
# Time the _track_token_usage calls
|
||||
iterations = 1000
|
||||
start_time = time.time()
|
||||
|
||||
for i in range(iterations):
|
||||
# Simulate the optimized conditional call
|
||||
if llm_no_metrics.metrics:
|
||||
llm_no_metrics._track_token_usage(mock_response, "test-model")
|
||||
|
||||
no_metrics_time = time.time() - start_time
|
||||
|
||||
# Test with metrics enabled
|
||||
print("📊 Testing with metrics=True...")
|
||||
llm_with_metrics = LLM(model="test-model", metrics=True)
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
for i in range(iterations):
|
||||
# Simulate the optimized conditional call
|
||||
if llm_with_metrics.metrics:
|
||||
llm_with_metrics._track_token_usage(mock_response, "test-model")
|
||||
|
||||
with_metrics_time = time.time() - start_time
|
||||
|
||||
print(f"\n🎯 Performance Results (n={iterations}):")
|
||||
print(f" metrics=False: {no_metrics_time:.6f} seconds")
|
||||
print(f" metrics=True: {with_metrics_time:.6f} seconds")
|
||||
print(f" Overhead when disabled: {no_metrics_time:.6f} seconds")
|
||||
|
||||
# Check if metrics=False has minimal overhead
|
||||
if no_metrics_time < 0.001: # Less than 1ms for 1000 iterations
|
||||
print("✅ SUCCESS: metrics=False has minimal overhead!")
|
||||
else:
|
||||
print("⚠️ WARNING: metrics=False may have some overhead")
|
||||
|
||||
# Verify metrics tracking works when enabled
|
||||
if hasattr(llm_with_metrics, 'last_token_metrics') and llm_with_metrics.last_token_metrics:
|
||||
print("✅ SUCCESS: Token tracking works when metrics=True")
|
||||
else:
|
||||
print("⚠️ Note: Token tracking may require full initialization")
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error during performance test: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_performance_impact()
|
||||
@@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify that metrics=True is properly passed from Agent to LLM instance.
|
||||
This test verifies the fix without requiring an actual API call.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Add the source path
|
||||
sys.path.insert(0, '/home/runner/work/PraisonAI/PraisonAI/src/praisonai-agents')
|
||||
|
||||
try:
|
||||
from praisonaiagents import Agent
|
||||
|
||||
print("✅ Testing Agent with metrics=True parameter...")
|
||||
|
||||
# Test 1: Agent with string LLM and metrics=True
|
||||
agent = Agent(
|
||||
name="Test Agent",
|
||||
role="Test Role",
|
||||
goal="Test Goal",
|
||||
backstory="Test backstory",
|
||||
llm="gpt-4o-mini",
|
||||
metrics=True,
|
||||
base_url="http://localhost:1234/v1", # Use local URL to trigger LLM instance creation
|
||||
api_key="test-key"
|
||||
)
|
||||
|
||||
# Check if LLM instance was created
|
||||
if hasattr(agent, 'llm_instance') and agent.llm_instance:
|
||||
print("✅ LLM instance created successfully")
|
||||
|
||||
# Check if metrics parameter was passed
|
||||
if hasattr(agent.llm_instance, 'metrics') and agent.llm_instance.metrics == True:
|
||||
print("✅ SUCCESS: metrics=True was properly passed to LLM instance!")
|
||||
print(f" Agent.metrics: {agent.metrics}")
|
||||
print(f" LLM.metrics: {agent.llm_instance.metrics}")
|
||||
else:
|
||||
print(f"❌ FAILED: metrics parameter not passed correctly")
|
||||
print(f" Agent.metrics: {agent.metrics}")
|
||||
print(f" LLM.metrics: {getattr(agent.llm_instance, 'metrics', 'NOT_FOUND')}")
|
||||
else:
|
||||
print("❌ LLM instance not created")
|
||||
|
||||
# Test 2: Agent with dict LLM config and metrics=True
|
||||
print("\n✅ Testing Agent with dict LLM config and metrics=True...")
|
||||
|
||||
agent2 = Agent(
|
||||
name="Test Agent 2",
|
||||
role="Test Role",
|
||||
goal="Test Goal",
|
||||
backstory="Test backstory",
|
||||
llm={"model": "gpt-4o-mini", "base_url": "http://localhost:1234/v1"},
|
||||
metrics=True,
|
||||
api_key="test-key"
|
||||
)
|
||||
|
||||
if hasattr(agent2, 'llm_instance') and agent2.llm_instance:
|
||||
print("✅ LLM instance created successfully")
|
||||
|
||||
if hasattr(agent2.llm_instance, 'metrics') and agent2.llm_instance.metrics == True:
|
||||
print("✅ SUCCESS: metrics=True was properly passed to LLM instance!")
|
||||
print(f" Agent.metrics: {agent2.metrics}")
|
||||
print(f" LLM.metrics: {agent2.llm_instance.metrics}")
|
||||
else:
|
||||
print(f"❌ FAILED: metrics parameter not passed correctly")
|
||||
print(f" Agent.metrics: {agent2.metrics}")
|
||||
print(f" LLM.metrics: {getattr(agent2.llm_instance, 'metrics', 'NOT_FOUND')}")
|
||||
else:
|
||||
print("❌ LLM instance not created")
|
||||
|
||||
# Test 3: Agent with provider/model format and metrics=True
|
||||
print("\n✅ Testing Agent with provider/model format and metrics=True...")
|
||||
|
||||
agent3 = Agent(
|
||||
name="Test Agent 3",
|
||||
role="Test Role",
|
||||
goal="Test Goal",
|
||||
backstory="Test backstory",
|
||||
llm="openai/gpt-4o-mini",
|
||||
metrics=True,
|
||||
api_key="test-key"
|
||||
)
|
||||
|
||||
if hasattr(agent3, 'llm_instance') and agent3.llm_instance:
|
||||
print("✅ LLM instance created successfully")
|
||||
|
||||
if hasattr(agent3.llm_instance, 'metrics') and agent3.llm_instance.metrics == True:
|
||||
print("✅ SUCCESS: metrics=True was properly passed to LLM instance!")
|
||||
print(f" Agent.metrics: {agent3.metrics}")
|
||||
print(f" LLM.metrics: {agent3.llm_instance.metrics}")
|
||||
else:
|
||||
print(f"❌ FAILED: metrics parameter not passed correctly")
|
||||
print(f" Agent.metrics: {agent3.metrics}")
|
||||
print(f" LLM.metrics: {getattr(agent3.llm_instance, 'metrics', 'NOT_FOUND')}")
|
||||
else:
|
||||
print("❌ LLM instance not created")
|
||||
|
||||
print("\n🎯 Token tracking fix verification complete!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error during test: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
Generated
+1
-1
@@ -2422,7 +2422,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonaiagents"
|
||||
version = "0.0.153"
|
||||
version = "0.0.154"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "aiohttp" },
|
||||
|
||||
@@ -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.79.tar.gz"
|
||||
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.79.tar.gz | shasum -a 256`.split.first
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.80.tar.gz"
|
||||
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.80.tar.gz | shasum -a 256`.split.first
|
||||
license "MIT"
|
||||
|
||||
depends_on "[email protected]"
|
||||
|
||||
@@ -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.79 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.2.80 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "PraisonAI"
|
||||
version = "2.2.79"
|
||||
version = "2.2.80"
|
||||
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.153",
|
||||
"praisonaiagents>=0.0.154",
|
||||
"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.79"
|
||||
version = "2.2.80"
|
||||
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.153"
|
||||
praisonaiagents = ">=0.0.154"
|
||||
python-dotenv = ">=0.19.0"
|
||||
instructor = ">=1.3.3"
|
||||
PyYAML = ">=6.0"
|
||||
|
||||
Generated
+5
-5
@@ -4031,7 +4031,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonai"
|
||||
version = "2.2.79"
|
||||
version = "2.2.80"
|
||||
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.153" },
|
||||
{ name = "praisonaiagents", specifier = ">=0.0.154" },
|
||||
{ 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.153"
|
||||
version = "0.0.154"
|
||||
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/2d/68/a47a148a7732f5236e5937abc75c0c5d6b1c55be487644348992f132f150/praisonaiagents-0.0.153.tar.gz", hash = "sha256:6da8d098f5774d929a6595c66ea7228a670f6ad4d3af851dc889df776b2407d3", size = 281822, upload-time = "2025-07-26T19:36:30.824Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/08/5e/2281af8cb62ffd33900fab88d013f4ef49850d788d03417b36e4b19a3be8/praisonaiagents-0.0.154.tar.gz", hash = "sha256:08f2889a5b16edbf232e0419dd827c101dcd659a16bba49f0811eabd77eecc72", size = 282697, upload-time = "2025-07-28T17:42:40.882Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/27/5b/44a2fe9ba1e6e3127255eb950e87a72b30ed8238035989318792903a138b/praisonaiagents-0.0.153-py3-none-any.whl", hash = "sha256:db050b7bc127f429fd3285c2a35cc68c1c94008a49a097909b2b8bbd4d6ad11f", size = 301026, upload-time = "2025-07-26T19:36:29.012Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/61/3e/5504dba65588125088250999a2c710c99d0fe2ae9e1449bb9afa4b917bf9/praisonaiagents-0.0.154-py3-none-any.whl", hash = "sha256:181aa61da8bbcc62d777396edccb28fcb49f32f44aa654fab8fffb2a7db36ba4", size = 301856, upload-time = "2025-07-28T17:42:39.05Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in new issue
Block a user