praisonaiagents 0.0.143__py3-none-any.whl → 0.0.145__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': []}
@@ -10,9 +10,19 @@ from datetime import datetime
10
10
  # Disable litellm telemetry before any imports
11
11
  os.environ["LITELLM_TELEMETRY"] = "False"
12
12
 
13
- # Set up logger
13
+ # Set up logger with custom TRACE level
14
14
  logger = logging.getLogger(__name__)
15
15
 
16
+ # Add custom TRACE level (below DEBUG)
17
+ TRACE_LEVEL = 5
18
+ logging.addLevelName(TRACE_LEVEL, 'TRACE')
19
+
20
+ def trace(self, message, *args, **kwargs):
21
+ if self.isEnabledFor(TRACE_LEVEL):
22
+ self._log(TRACE_LEVEL, message, args, **kwargs)
23
+
24
+ logging.Logger.trace = trace
25
+
16
26
  try:
17
27
  import chromadb
18
28
  from chromadb.config import Settings as ChromaSettings
@@ -770,7 +780,7 @@ class Memory:
770
780
  import litellm
771
781
 
772
782
  logger.info("Getting embeddings from LiteLLM...")
773
- logger.debug(f"Embedding input text: {text}")
783
+ logger.trace(f"Embedding input text: {text}")
774
784
 
775
785
  response = litellm.embedding(
776
786
  model=self.embedding_model,
@@ -778,7 +788,7 @@ class Memory:
778
788
  )
779
789
  embedding = response.data[0]["embedding"]
780
790
  logger.info("Successfully got embeddings from LiteLLM")
781
- logger.debug(f"Received embedding of length: {len(embedding)}")
791
+ logger.trace(f"Received embedding of length: {len(embedding)}")
782
792
 
783
793
  elif OPENAI_AVAILABLE:
784
794
  # Fallback to OpenAI client
@@ -786,7 +796,7 @@ class Memory:
786
796
  client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
787
797
 
788
798
  logger.info("Getting embeddings from OpenAI...")
789
- logger.debug(f"Embedding input text: {text}")
799
+ logger.trace(f"Embedding input text: {text}")
790
800
 
791
801
  response = client.embeddings.create(
792
802
  input=text,
@@ -794,7 +804,7 @@ class Memory:
794
804
  )
795
805
  embedding = response.data[0].embedding
796
806
  logger.info("Successfully got embeddings from OpenAI")
797
- logger.debug(f"Received embedding of length: {len(embedding)}")
807
+ logger.trace(f"Received embedding of length: {len(embedding)}")
798
808
  else:
799
809
  logger.warning("Neither litellm nor openai available for embeddings")
800
810
  return
@@ -1243,12 +1253,22 @@ class Memory:
1243
1253
  task_descr: str,
1244
1254
  user_id: Optional[str] = None,
1245
1255
  additional: str = "",
1246
- max_items: int = 3
1256
+ max_items: int = 3,
1257
+ include_in_output: Optional[bool] = None
1247
1258
  ) -> str:
1248
1259
  """
1249
1260
  Merges relevant short-term, long-term, entity, user memories
1250
1261
  into a single text block with deduplication and clean formatting.
1262
+
1263
+ Args:
1264
+ include_in_output: If None, memory content is only included when debug logging is enabled.
1265
+ If True, memory content is always included.
1266
+ If False, memory content is never included (only logged for debugging).
1251
1267
  """
1268
+ # Determine whether to include memory content in output based on logging level
1269
+ if include_in_output is None:
1270
+ include_in_output = logging.getLogger().getEffectiveLevel() == logging.DEBUG
1271
+
1252
1272
  q = (task_descr + " " + additional).strip()
1253
1273
  lines = []
1254
1274
  seen_contents = set() # Track unique contents
@@ -1306,16 +1326,20 @@ class Memory:
1306
1326
  formatted_hits.append(formatted)
1307
1327
 
1308
1328
  if formatted_hits:
1309
- # Add section header
1310
- if lines:
1311
- lines.append("") # Space before new section
1312
- lines.append(title)
1313
- lines.append("=" * len(title)) # Underline the title
1314
- lines.append("") # Space after title
1329
+ # Log detailed memory content for debugging including section headers
1330
+ brief_title = title.replace(" Context", "").replace("Memory ", "")
1331
+ logger.debug(f"Memory section '{brief_title}' ({len(formatted_hits)} items): {formatted_hits}")
1315
1332
 
1316
- # Add formatted content with bullet points
1317
- for content in formatted_hits:
1318
- lines.append(f" {content}")
1333
+ # Only include memory content in output when specified (controlled by log level or explicit parameter)
1334
+ if include_in_output:
1335
+ # Add only the actual memory content for AI agent use (no headers)
1336
+ if lines:
1337
+ lines.append("") # Space before new section
1338
+
1339
+ # Include actual memory content without verbose section headers
1340
+ for hit in formatted_hits:
1341
+ lines.append(f"• {hit}")
1342
+ lines.append("") # Space after content
1319
1343
 
1320
1344
  # Add each section
1321
1345
  # First get all results
@@ -402,13 +402,14 @@ Expected Output: {self.expected_output}.
402
402
  context_results.append(f"Input Content: {' '.join(str(x) for x in context_item)}")
403
403
  elif hasattr(context_item, 'result'): # Task object
404
404
  if context_item.result:
405
- context_results.append(
406
- f"Result of previous task {context_item.name if context_item.name else context_item.description}:\n{context_item.result.raw}"
407
- )
405
+ task_name = context_item.name if context_item.name else context_item.description
406
+ # Log detailed result for debugging
407
+ logger.debug(f"Previous task '{task_name}' result: {context_item.result.raw}")
408
+ # Include actual result content without verbose labels (essential for task chaining)
409
+ context_results.append(context_item.result.raw)
408
410
  else:
409
- context_results.append(
410
- f"Previous task {context_item.name if context_item.name else context_item.description} has no result yet."
411
- )
411
+ # Task has no result yet, don't include verbose status message
412
+ pass
412
413
 
413
414
  # Join unique context results
414
415
  unique_contexts = list(dict.fromkeys(context_results)) # Remove duplicates
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: praisonaiagents
3
- Version: 0.0.143
3
+ Version: 0.0.145
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
6
  Requires-Python: >=3.10
@@ -1,21 +1,22 @@
1
- praisonaiagents/__init__.py,sha256=z-j8jnweyyG_T7C-SLMdHBlzjHrkeUdQSZNExSuRTaw,4038
1
+ praisonaiagents/__init__.py,sha256=q0E8kxVTsw8B_mESv74GFhH4mDgiD26kcFMOFB0FoL0,4154
2
2
  praisonaiagents/approval.py,sha256=UJ4OhfihpFGR5CAaMphqpSvqdZCHi5w2MGw1MByZ1FQ,9813
3
3
  praisonaiagents/main.py,sha256=b5dKlkf6NMeumSzixreHB9ui90f8YMAi5r1fCbTpQVw,17225
4
4
  praisonaiagents/session.py,sha256=FHWButPBaFGA4x1U_2gImroQChHnFy231_aAa_n5KOQ,20364
5
- praisonaiagents/agent/__init__.py,sha256=FkjW6f3EU8heQ9tvctfLbOWV9_dOXmS1PcFNgcStns8,403
6
- praisonaiagents/agent/agent.py,sha256=Vu8nNGOndNa5I3VT5hPbMBhWCw9i24tzc7yPSwf9jvs,127439
5
+ praisonaiagents/agent/__init__.py,sha256=KBqW_augD-HcaV3FL88gUmhDCpwnSTavGENi7RqneTo,505
6
+ praisonaiagents/agent/agent.py,sha256=1wI2Ohp9evUza7qlZt3yIu4goroR8Jm8EIenXaOpDso,125805
7
+ praisonaiagents/agent/context_agent.py,sha256=zNI2Waghn5eo8g3QM1Dc7ZNSr2xw41D87GIK81FjW-Y,107489
7
8
  praisonaiagents/agent/handoff.py,sha256=Saq0chqfvC6Zf5UbXvmctybbehqnotrXn72JsS-76Q0,13099
8
9
  praisonaiagents/agent/image_agent.py,sha256=xKDhW8T1Y3e15lQpY6N2pdvBNJmAoWDibJa4BYa-Njs,10205
9
10
  praisonaiagents/agent/router_agent.py,sha256=a_b6w5Ti05gvK80uKGMIcT14fiCTKv8rCQPCWAUfIiE,12713
10
11
  praisonaiagents/agents/__init__.py,sha256=_1d6Pqyk9EoBSo7E68sKyd1jDRlN1vxvVIRpoMc0Jcw,168
11
- praisonaiagents/agents/agents.py,sha256=DkBgdE6hK22qkJjufYXNGDXTM1vsAv-nf4RyhPX6sEs,64768
12
+ praisonaiagents/agents/agents.py,sha256=POZ-CbFabOSY7UUBDgh5IE6bXv0qERPO4Hpah6MSvQ8,65983
12
13
  praisonaiagents/agents/autoagents.py,sha256=v5pJfTgHnFzG5K2gHwfRA0nZ7Ikptir6hUNvOZ--E44,20777
13
14
  praisonaiagents/guardrails/__init__.py,sha256=HA8zhp-KRHTxo0194MUwXOUJjPyjOu7E3d7xUIKYVVY,310
14
15
  praisonaiagents/guardrails/guardrail_result.py,sha256=2K1WIYRyT_s1H6vBGa-7HEHzXCFIyZXZVY4f0hnQyWc,1352
15
16
  praisonaiagents/guardrails/llm_guardrail.py,sha256=czdOIoY-3PZOchX317tz4O2h2WYE42Ua4tqVzyuoNlI,4859
16
17
  praisonaiagents/knowledge/__init__.py,sha256=xL1Eh-a3xsHyIcU4foOWF-JdWYIYBALJH9bge0Ujuto,246
17
18
  praisonaiagents/knowledge/chunking.py,sha256=G6wyHa7_8V0_7VpnrrUXbEmUmptlT16ISJYaxmkSgmU,7678
18
- praisonaiagents/knowledge/knowledge.py,sha256=xZJMMsz3LGSvs_EUao2VtdGGYlLRokVTkFykCOBOjlY,29545
19
+ praisonaiagents/knowledge/knowledge.py,sha256=OzK81oA6sjk9nAUWphS7AkXxvalrv2AHB4FtHjzYgxI,30115
19
20
  praisonaiagents/llm/__init__.py,sha256=tHvWq5mv4K4MhWr0s6rqox8UnJ5RK0kXhYuD40WkZQA,1747
20
21
  praisonaiagents/llm/llm.py,sha256=vBw810jpgjZyVAvHcGAG0-QpdbL5e2DBwjn8qgE5NXc,136663
21
22
  praisonaiagents/llm/model_capabilities.py,sha256=cxOvZcjZ_PIEpUYKn3S2FMyypfOSfbGpx4vmV7Y5vhI,3967
@@ -26,11 +27,11 @@ praisonaiagents/mcp/mcp.py,sha256=ChaSwLCcFBB9b8eNuj0DoKbK1EqpyF1T_7xz0FX-5-A,23
26
27
  praisonaiagents/mcp/mcp_http_stream.py,sha256=Yh-69eIlLQS_M0bd__y7NzSjOqqX6R8Ed4eJQw6xXgg,18314
27
28
  praisonaiagents/mcp/mcp_sse.py,sha256=KO10tAgZ5vSKeRhkJIZcdJ0ZmhRybS39i1KybWt4D7M,9128
28
29
  praisonaiagents/memory/__init__.py,sha256=aEFdhgtTqDdMhc_JCWM-f4XI9cZIj7Wz5g_MUa-0amg,397
29
- praisonaiagents/memory/memory.py,sha256=oS0mpOZO99b1QJZ96mDcOp1S_yNS52JO-9XiBVbmiHE,61608
30
+ praisonaiagents/memory/memory.py,sha256=TqaNYkoySuHvzCNyA8nrilbSJYzKPfWllmDZzY6rLuY,62918
30
31
  praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
31
32
  praisonaiagents/process/process.py,sha256=wXKZ2Z26vB9osmVbD5xqkUlUQRvWEpvL8j9hiuiHrQ0,78246
32
33
  praisonaiagents/task/__init__.py,sha256=VL5hXVmyGjINb34AalxpBMl-YW9m5EDcRkMTKkSSl7c,80
33
- praisonaiagents/task/task.py,sha256=-EXxw3czWZdAK1WWI6Dvga5CujsItgk9RWYD_CdW47w,24075
34
+ praisonaiagents/task/task.py,sha256=j1KgaqeMfVm7lcO3puyIjX1r8Uf5GHtTRvd4NlK5Vk8,24203
34
35
  praisonaiagents/telemetry/__init__.py,sha256=jeo0tJxISEt565StmFZGCJcz7AYDoN-4dEkR_ikRv5s,3329
35
36
  praisonaiagents/telemetry/integration.py,sha256=8h8TDlPFTbsBmU5rIYNOibJbwEEEWmzS1ENE9uPTvvg,8696
36
37
  praisonaiagents/telemetry/telemetry.py,sha256=7IDBoTE0Z9ajaTZmIo3r3rJaMSFG-GdEK9dx5YNLPx0,23215
@@ -58,7 +59,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
58
59
  praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
59
60
  praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
60
61
  praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
61
- praisonaiagents-0.0.143.dist-info/METADATA,sha256=N0xvQUdcsKYAVsmFGXHh97-P5WsqlXvWfoSkCrEbkO0,1851
62
- praisonaiagents-0.0.143.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
63
- praisonaiagents-0.0.143.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
64
- praisonaiagents-0.0.143.dist-info/RECORD,,
62
+ praisonaiagents-0.0.145.dist-info/METADATA,sha256=V5JX8PHc9bCzOKO3hwqO7GTXZ78u5RkKxjQocX4A_Dc,1851
63
+ praisonaiagents-0.0.145.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
64
+ praisonaiagents-0.0.145.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
65
+ praisonaiagents-0.0.145.dist-info/RECORD,,