praisonaiagents 0.0.144__py3-none-any.whl → 0.0.146__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,16 +81,19 @@ def process_task_context(context_item, verbose=0, user_id=None):
81
81
  task_name = context_item.name if context_item.name else context_item.description
82
82
 
83
83
  if context_item.result and task_status == TaskStatus.COMPLETED.value:
84
- return f"Result of previous task {task_name}:\n{context_item.result.raw}"
84
+ # Log detailed result for debugging
85
+ logger.debug(f"Previous task '{task_name}' result: {context_item.result.raw}")
86
+ # Return actual result content without verbose label (essential for task chaining)
87
+ return context_item.result.raw
85
88
  elif task_status == TaskStatus.COMPLETED.value and not context_item.result:
86
- return f"Previous task {task_name} completed but produced no result."
89
+ return "" # No result to include
87
90
  else:
88
- return f"Previous task {task_name} is not yet completed (status: {task_status or TaskStatus.UNKNOWN.value})."
89
- elif isinstance(context_item, dict) and "vector_store" in context_item:
91
+ return "" # Task not completed, no context to include
92
+ elif isinstance(context_item, dict) and ("vector_store" in context_item or "embedding_db_config" in context_item):
90
93
  from ..knowledge.knowledge import Knowledge
91
94
  try:
92
- # Handle both string and dict configs
93
- cfg = context_item["vector_store"]
95
+ # Handle both string and dict configs - support both vector_store and embedding_db_config keys for backward compatibility
96
+ cfg = context_item.get("vector_store") or context_item.get("embedding_db_config")
94
97
  if isinstance(cfg, str):
95
98
  cfg = json.loads(cfg)
96
99
 
@@ -101,9 +104,19 @@ def process_task_context(context_item, verbose=0, user_id=None):
101
104
  context_item.get("query", ""), # Use query from context if available
102
105
  user_id=user_id if user_id else None
103
106
  )
104
- return f"[DB Context]: {str(db_results)}"
107
+
108
+ # Log knowledge results for debugging (always available for troubleshooting)
109
+ logger.debug(f"Knowledge search results ({len(db_results)} items): {str(db_results)}")
110
+
111
+ # Return actual content without verbose "[DB Context]:" prefix
112
+ return str(db_results)
105
113
  except Exception as e:
106
- return f"[Vector DB Error]: {e}"
114
+ # Log error for debugging (always available for troubleshooting)
115
+ logger.debug(f"Vector DB Error: {e}")
116
+
117
+ # Return empty string to avoid exposing error details in AI prompts
118
+ # Error details are preserved in debug logs for troubleshooting
119
+ return ""
107
120
  else:
108
121
  return str(context_item) # Fallback for unknown types
109
122
 
@@ -148,7 +161,9 @@ class PraisonAIAgents:
148
161
 
149
162
  # Set logger level based on verbose
150
163
  if verbose >= 5:
151
- logger.setLevel(logging.INFO)
164
+ logger.setLevel(logging.INFO) # keep everything ≥INFO
165
+ elif verbose >= 3:
166
+ logger.setLevel(logging.DEBUG) # surface DEBUG when user asks for it
152
167
  else:
153
168
  logger.setLevel(logging.WARNING)
154
169
 
@@ -312,7 +327,7 @@ Expected Output: {task.expected_output}.
312
327
  if self.verbose >= 3:
313
328
  logger.info(f"Task {task_id} context items: {len(unique_contexts)}")
314
329
  for i, ctx in enumerate(unique_contexts):
315
- logger.info(f"Context {i+1}: {ctx[:100]}...")
330
+ logger.debug(f"Context {i+1}: {ctx[:100]}...")
316
331
  context_separator = '\n\n'
317
332
  task_prompt += f"""
318
333
  Context:
@@ -635,7 +650,7 @@ Expected Output: {task.expected_output}.
635
650
  if self.verbose >= 3:
636
651
  logger.info(f"Task {task_id} context items: {len(unique_contexts)}")
637
652
  for i, ctx in enumerate(unique_contexts):
638
- logger.info(f"Context {i+1}: {ctx[:100]}...")
653
+ logger.debug(f"Context {i+1}: {ctx[:100]}...")
639
654
  context_separator = '\n\n'
640
655
  task_prompt += f"""
641
656
  Context:
@@ -648,7 +663,10 @@ Context:
648
663
  try:
649
664
  memory_context = task.memory.build_context_for_task(task.description)
650
665
  if memory_context:
651
- task_prompt += f"\n\nRelevant memory context:\n{memory_context}"
666
+ # Log detailed memory context for debugging
667
+ logger.debug(f"Memory context for task '{task.description}': {memory_context}")
668
+ # Include actual memory content without verbose headers (essential for AI agent functionality)
669
+ task_prompt += f"\n\n{memory_context}"
652
670
  except Exception as e:
653
671
  logger.error(f"Error getting memory context: {e}")
654
672
 
@@ -714,7 +714,15 @@ class Knowledge:
714
714
  memory_result = self.store(memory, user_id=user_id, agent_id=agent_id,
715
715
  run_id=run_id, metadata=metadata)
716
716
  if memory_result:
717
- all_results.extend(memory_result.get('results', []))
717
+ # Handle both dict and list formats for backward compatibility
718
+ if isinstance(memory_result, dict):
719
+ all_results.extend(memory_result.get('results', []))
720
+ elif isinstance(memory_result, list):
721
+ all_results.extend(memory_result)
722
+ else:
723
+ # Log warning for unexpected types but don't break
724
+ import logging
725
+ logging.warning(f"Unexpected memory_result type: {type(memory_result)}, skipping")
718
726
  progress.advance(store_task)
719
727
 
720
728
  return {'results': all_results, 'relations': []}
@@ -1,19 +1,36 @@
1
1
  import logging
2
2
  import warnings
3
3
  import os
4
+ import re
4
5
 
5
6
  # Disable litellm telemetry before any imports
6
7
  os.environ["LITELLM_TELEMETRY"] = "False"
7
8
 
8
- # Suppress all relevant logs at module level - consistent with main __init__.py
9
- logging.getLogger("litellm").setLevel(logging.WARNING)
10
- logging.getLogger("openai").setLevel(logging.WARNING)
11
- logging.getLogger("httpx").setLevel(logging.WARNING)
12
- logging.getLogger("httpcore").setLevel(logging.WARNING)
13
- logging.getLogger("pydantic").setLevel(logging.WARNING)
9
+ # Check if warnings should be suppressed (consistent with main __init__.py)
10
+ def _should_suppress_warnings():
11
+ import sys
12
+ LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper()
13
+ return (LOGLEVEL != 'DEBUG' and
14
+ not hasattr(sys, '_called_from_test') and
15
+ 'pytest' not in sys.modules and
16
+ os.environ.get('PYTEST_CURRENT_TEST') is None)
14
17
 
15
- # Suppress pydantic warnings
16
- warnings.filterwarnings("ignore", category=UserWarning, module="pydantic")
18
+ # Suppress all relevant logs at module level - more aggressive suppression consistent with main __init__.py (only when not in DEBUG mode)
19
+ if _should_suppress_warnings():
20
+ logging.getLogger("litellm").setLevel(logging.CRITICAL)
21
+ logging.getLogger("openai").setLevel(logging.WARNING)
22
+ logging.getLogger("httpx").setLevel(logging.CRITICAL)
23
+ logging.getLogger("httpcore").setLevel(logging.CRITICAL)
24
+ logging.getLogger("pydantic").setLevel(logging.WARNING)
25
+
26
+ # Note: litellm child loggers automatically inherit the CRITICAL level from the parent logger
27
+
28
+ # Warning filters are centrally managed in the main __init__.py file
29
+ # Apply additional local suppression for safety during LLM imports (only when not in DEBUG mode)
30
+ if _should_suppress_warnings():
31
+ for module in ['litellm', 'httpx', 'httpcore', 'pydantic']:
32
+ warnings.filterwarnings("ignore", category=DeprecationWarning, module=module)
33
+ warnings.filterwarnings("ignore", category=UserWarning, module=module)
17
34
 
18
35
  # Import after suppressing warnings
19
36
  from .llm import LLM, LLMContextLengthExceededException
@@ -40,12 +57,21 @@ from .model_router import (
40
57
  create_routing_agent
41
58
  )
42
59
 
43
- # Ensure telemetry is disabled after import as well
44
- try:
45
- import litellm
46
- litellm.telemetry = False
47
- except ImportError:
48
- pass
60
+ # Ensure comprehensive litellm configuration after import (only when not in DEBUG mode)
61
+ if _should_suppress_warnings():
62
+ try:
63
+ import litellm
64
+ # Disable all litellm logging and telemetry features
65
+ litellm.telemetry = False
66
+ litellm.drop_params = True
67
+ if hasattr(litellm, 'suppress_debug_info'):
68
+ litellm.suppress_debug_info = True
69
+ # Set all litellm loggers to CRITICAL level
70
+ if hasattr(litellm, '_logging_obj'):
71
+ litellm._logging_obj.setLevel(logging.CRITICAL)
72
+ # Note: Child loggers inherit from parent, no need to iterate over all loggers
73
+ except ImportError:
74
+ pass
49
75
 
50
76
  __all__ = [
51
77
  "LLM",