praisonaiagents 0.0.88__py3-none-any.whl → 0.0.90__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.
@@ -8,10 +8,10 @@ It automatically handles agent creation, task setup, and execution flow.
8
8
  from .agents import PraisonAIAgents
9
9
  from ..agent.agent import Agent
10
10
  from ..task.task import Task
11
- from typing import List, Any, Optional, Dict
11
+ from typing import List, Any, Optional, Dict, Tuple
12
12
  import logging
13
13
  import os
14
- from pydantic import BaseModel
14
+ from pydantic import BaseModel, ConfigDict
15
15
  from ..main import display_instruction, display_tool_call, display_interaction, client
16
16
 
17
17
  # Define Pydantic models for structured output
@@ -22,6 +22,7 @@ class TaskConfig(BaseModel):
22
22
  tools: List[str]
23
23
 
24
24
  class AgentConfig(BaseModel):
25
+ model_config = ConfigDict(arbitrary_types_allowed=True)
25
26
  name: str
26
27
  role: str
27
28
  goal: str
@@ -30,6 +31,7 @@ class AgentConfig(BaseModel):
30
31
  tasks: List[TaskConfig]
31
32
 
32
33
  class AutoAgentsConfig(BaseModel):
34
+ model_config = ConfigDict(arbitrary_types_allowed=True)
33
35
  main_instruction: str
34
36
  process_type: str
35
37
  agents: List[AgentConfig]
@@ -255,7 +257,7 @@ Return the configuration in a structured JSON format matching the AutoAgentsConf
255
257
  logging.error(f"Error generating configuration: {e}")
256
258
  raise
257
259
 
258
- def _create_agents_and_tasks(self, config: AutoAgentsConfig) -> tuple[List[Agent], List[Task]]:
260
+ def _create_agents_and_tasks(self, config: AutoAgentsConfig) -> Tuple[List[Agent], List[Task]]:
259
261
  """Create agents and tasks from configuration"""
260
262
  agents = []
261
263
  tasks = []
@@ -283,7 +285,7 @@ Return the configuration in a structured JSON format matching the AutoAgentsConf
283
285
  respect_context_window=self.respect_context_window,
284
286
  code_execution_mode=self.code_execution_mode,
285
287
  embedder_config=self.embedder_config,
286
- knowledge_sources=self.knowledge_sources,
288
+ knowledge=self.knowledge_sources,
287
289
  use_system_prompt=self.use_system_prompt,
288
290
  cache=self.cache,
289
291
  allow_delegation=self.allow_delegation,
praisonaiagents/main.py CHANGED
@@ -4,7 +4,7 @@ import json
4
4
  import logging
5
5
  from typing import List, Optional, Dict, Any, Union, Literal, Type
6
6
  from openai import OpenAI
7
- from pydantic import BaseModel
7
+ from pydantic import BaseModel, ConfigDict
8
8
  from rich import print
9
9
  from rich.console import Console
10
10
  from rich.panel import Panel
@@ -365,6 +365,7 @@ class ReflectionOutput(BaseModel):
365
365
  client = OpenAI(api_key=(os.environ["OPENAI_API_KEY"] if os.environ.get("OPENAI_API_KEY") else "xxxx"))
366
366
 
367
367
  class TaskOutput(BaseModel):
368
+ model_config = ConfigDict(arbitrary_types_allowed=True)
368
369
  description: str
369
370
  summary: Optional[str] = None
370
371
  raw: str
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  import asyncio
3
3
  from typing import Dict, Optional, List, Any, AsyncGenerator
4
- from pydantic import BaseModel
4
+ from pydantic import BaseModel, ConfigDict
5
5
  from ..agent.agent import Agent
6
6
  from ..task.task import Task
7
7
  from ..main import display_error, client
@@ -9,6 +9,7 @@ import csv
9
9
  import os
10
10
 
11
11
  class LoopItems(BaseModel):
12
+ model_config = ConfigDict(arbitrary_types_allowed=True)
12
13
  items: List[Any]
13
14
 
14
15
  class Process:
@@ -30,6 +31,44 @@ class Process:
30
31
  self.task_retry_counter: Dict[str, int] = {} # Initialize retry counter
31
32
  self.workflow_finished = False # ADDED: Workflow finished flag
32
33
 
34
+ def _build_task_context(self, current_task: Task) -> str:
35
+ """Build context for a task based on its retain_full_context setting"""
36
+ if not (current_task.previous_tasks or current_task.context):
37
+ return ""
38
+
39
+ context = "\nInput data from previous tasks:"
40
+
41
+ if current_task.retain_full_context:
42
+ # Original behavior: include all previous tasks
43
+ for prev_name in current_task.previous_tasks:
44
+ prev_task = next((t for t in self.tasks.values() if t.name == prev_name), None)
45
+ if prev_task and prev_task.result:
46
+ context += f"\n{prev_name}: {prev_task.result.raw}"
47
+
48
+ # Add data from context tasks
49
+ if current_task.context:
50
+ for ctx_task in current_task.context:
51
+ if ctx_task.result and ctx_task.name != current_task.name:
52
+ context += f"\n{ctx_task.name}: {ctx_task.result.raw}"
53
+ else:
54
+ # New behavior: only include the most recent previous task
55
+ if current_task.previous_tasks:
56
+ # Get the most recent previous task (last in the list)
57
+ prev_name = current_task.previous_tasks[-1]
58
+ prev_task = next((t for t in self.tasks.values() if t.name == prev_name), None)
59
+ if prev_task and prev_task.result:
60
+ context += f"\n{prev_name}: {prev_task.result.raw}"
61
+
62
+ # For context tasks, still include the most recent one
63
+ if current_task.context:
64
+ # Get the most recent context task with a result
65
+ for ctx_task in reversed(current_task.context):
66
+ if ctx_task.result and ctx_task.name != current_task.name:
67
+ context += f"\n{ctx_task.name}: {ctx_task.result.raw}"
68
+ break # Only include the most recent one
69
+
70
+ return context
71
+
33
72
  def _find_next_not_started_task(self) -> Optional[Task]:
34
73
  """Fallback mechanism to find the next 'not started' task."""
35
74
  fallback_attempts = 0
@@ -147,25 +186,8 @@ Description length: {len(current_task.description)}
147
186
  """)
148
187
 
149
188
  # Add context from previous tasks to description
150
- if current_task.previous_tasks or current_task.context:
151
- context = "\nInput data from previous tasks:"
152
-
153
- # Add data from previous tasks in workflow
154
- for prev_name in current_task.previous_tasks:
155
- prev_task = next((t for t in self.tasks.values() if t.name == prev_name), None)
156
- if prev_task and prev_task.result:
157
- # Handle loop data
158
- if current_task.task_type == "loop":
159
- context += f"\n{prev_name}: {prev_task.result.raw}"
160
- else:
161
- context += f"\n{prev_name}: {prev_task.result.raw}"
162
-
163
- # Add data from context tasks
164
- if current_task.context:
165
- for ctx_task in current_task.context:
166
- if ctx_task.result and ctx_task.name != current_task.name:
167
- context += f"\n{ctx_task.name}: {ctx_task.result.raw}"
168
-
189
+ context = self._build_task_context(current_task)
190
+ if context:
169
191
  # Update task description with context
170
192
  current_task.description = current_task.description + context
171
193
 
@@ -778,25 +800,8 @@ Description length: {len(current_task.description)}
778
800
  """)
779
801
 
780
802
  # Add context from previous tasks to description
781
- if current_task.previous_tasks or current_task.context:
782
- context = "\nInput data from previous tasks:"
783
-
784
- # Add data from previous tasks in workflow
785
- for prev_name in current_task.previous_tasks:
786
- prev_task = next((t for t in self.tasks.values() if t.name == prev_name), None)
787
- if prev_task and prev_task.result:
788
- # Handle loop data
789
- if current_task.task_type == "loop":
790
- context += f"\n{prev_name}: {prev_task.result.raw}"
791
- else:
792
- context += f"\n{prev_name}: {prev_task.result.raw}"
793
-
794
- # Add data from context tasks
795
- if current_task.context:
796
- for ctx_task in current_task.context:
797
- if ctx_task.result and ctx_task.name != current_task.name:
798
- context += f"\n{ctx_task.name}: {ctx_task.result.raw}"
799
-
803
+ context = self._build_task_context(current_task)
804
+ if context:
800
805
  # Update task description with context
801
806
  current_task.description = current_task.description + context
802
807
 
@@ -39,7 +39,8 @@ class Task:
39
39
  memory=None,
40
40
  quality_check=True,
41
41
  input_file: Optional[str] = None,
42
- rerun: bool = False # Renamed from can_rerun and logic inverted, default True for backward compatibility
42
+ rerun: bool = False, # Renamed from can_rerun and logic inverted, default True for backward compatibility
43
+ retain_full_context: bool = False # By default, only use previous task output, not all previous tasks
43
44
  ):
44
45
  # Add check if memory config is provided
45
46
  if memory is not None or (config and config.get('memory_config')):
@@ -78,6 +79,7 @@ class Task:
78
79
  self.memory = memory
79
80
  self.quality_check = quality_check
80
81
  self.rerun = rerun # Assigning the rerun parameter
82
+ self.retain_full_context = retain_full_context
81
83
 
82
84
  # Set logger level based on config verbose level
83
85
  verbose = self.config.get("verbose", 0)
@@ -213,9 +215,20 @@ class Task:
213
215
  logger.info(f"Task {self.id}: Calculating quality metrics for output: {task_output.raw[:100]}...")
214
216
 
215
217
  # Get quality metrics from LLM
218
+ # Determine which LLM model to use based on agent configuration
219
+ llm_model = None
220
+ if self.agent:
221
+ if getattr(self.agent, '_using_custom_llm', False) and hasattr(self.agent, 'llm_instance'):
222
+ # For custom LLM instances (like Ollama)
223
+ llm_model = self.agent.llm_instance
224
+ elif hasattr(self.agent, 'llm') and self.agent.llm:
225
+ # For standard model strings
226
+ llm_model = self.agent.llm
227
+
216
228
  metrics = self.memory.calculate_quality_metrics(
217
229
  task_output.raw,
218
- self.expected_output
230
+ self.expected_output,
231
+ llm=llm_model
219
232
  )
220
233
  logger.info(f"Task {self.id}: Quality metrics calculated: {metrics}")
221
234
 
@@ -1,8 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: praisonaiagents
3
- Version: 0.0.88
3
+ Version: 0.0.90
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
+ Requires-Python: >=3.10
6
7
  Requires-Dist: pydantic
7
8
  Requires-Dist: rich
8
9
  Requires-Dist: openai
@@ -1,11 +1,11 @@
1
1
  praisonaiagents/__init__.py,sha256=Z2_rSA6mYozz0r3ioUgKzl3QV8uWRDS_QaqPg2oGjqg,1324
2
- praisonaiagents/main.py,sha256=l29nGEbV2ReBi4szURbnH0Fk0w2F_QZTmECysyZjYcA,15066
2
+ praisonaiagents/main.py,sha256=EsMRCT1tYjHH7hgoXov5s1caIBeRkpIPK8EZQsMKlw4,15138
3
3
  praisonaiagents/agent/__init__.py,sha256=j0T19TVNbfZcClvpbZDDinQxZ0oORgsMrMqx16jZ-bA,128
4
4
  praisonaiagents/agent/agent.py,sha256=-zENKxcaAWH5KJOed4KmcpAeBDNtRlxqG58QHdLH6RA,86334
5
5
  praisonaiagents/agent/image_agent.py,sha256=-5MXG594HVwSpFMcidt16YBp7udtik-Cp7eXlzLE1fY,8696
6
6
  praisonaiagents/agents/__init__.py,sha256=_1d6Pqyk9EoBSo7E68sKyd1jDRlN1vxvVIRpoMc0Jcw,168
7
7
  praisonaiagents/agents/agents.py,sha256=lFWJDZeWQcr6RttV-pxvny-jfAM3UWiYjMnYo8pZYe0,59429
8
- praisonaiagents/agents/autoagents.py,sha256=olYDn--rlJp-SckxILqmREkkgNlzCgEEcAUzfMj-54E,13518
8
+ praisonaiagents/agents/autoagents.py,sha256=Lc_b9mO2MeefBrsHkHoqFxEr5iRGrYuzDhslyybXwdw,13649
9
9
  praisonaiagents/knowledge/__init__.py,sha256=xL1Eh-a3xsHyIcU4foOWF-JdWYIYBALJH9bge0Ujuto,246
10
10
  praisonaiagents/knowledge/chunking.py,sha256=G6wyHa7_8V0_7VpnrrUXbEmUmptlT16ISJYaxmkSgmU,7678
11
11
  praisonaiagents/knowledge/knowledge.py,sha256=Po0JZsgjYJrXdNSggmUGOWidZEF0f8xo4nhsZZfh8tY,13217
@@ -16,9 +16,9 @@ praisonaiagents/mcp/mcp.py,sha256=-U6md6zHoJZCWF8XFq921Yy5CcSNaGqvjg3aRT737LM,16
16
16
  praisonaiagents/mcp/mcp_sse.py,sha256=DLh3F_aoVRM1X-7hgIOWOw4FQ1nGmn9YNbQTesykzn4,6792
17
17
  praisonaiagents/memory/memory.py,sha256=I8dOTkrl1i-GgQbDcrFOsSruzJ7MiI6Ys37DK27wrUs,35537
18
18
  praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
19
- praisonaiagents/process/process.py,sha256=HPw84OhnKQW3EyrDkpoQu0DcpxThbrzR2hWUgwQh9Pw,59955
19
+ praisonaiagents/process/process.py,sha256=7nGV-d9lDlQO6d7X4nMb7f6pMKCYNfoFzTrVvPrUefo,60179
20
20
  praisonaiagents/task/__init__.py,sha256=VL5hXVmyGjINb34AalxpBMl-YW9m5EDcRkMTKkSSl7c,80
21
- praisonaiagents/task/task.py,sha256=8KztSUKMO74y619TyI8d5DMJ1xPbyQXIB0Ux583oOVw,14259
21
+ praisonaiagents/task/task.py,sha256=JShYyMkAC1_bhEt0s0CXwJtQFXY6bNu-rlb0mHyyoXM,15034
22
22
  praisonaiagents/tools/__init__.py,sha256=CWOYV9SudYY82r45LnNgaVRV3cmsAFdasNRkPrLsgmI,9198
23
23
  praisonaiagents/tools/arxiv_tools.py,sha256=1stb31zTjLTon4jCnpZG5de9rKc9QWgC0leLegvPXWo,10528
24
24
  praisonaiagents/tools/calculator_tools.py,sha256=S1xPT74Geurvjm52QMMIG29zDXVEWJmM6nmyY7yF298,9571
@@ -40,7 +40,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
40
40
  praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
41
41
  praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
42
42
  praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
43
- praisonaiagents-0.0.88.dist-info/METADATA,sha256=p9uG4zmHdSBsddSEP1qMPi-mGztIUp0k92pYWGpnMDQ,1244
44
- praisonaiagents-0.0.88.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
45
- praisonaiagents-0.0.88.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
46
- praisonaiagents-0.0.88.dist-info/RECORD,,
43
+ praisonaiagents-0.0.90.dist-info/METADATA,sha256=HrNS7WT3LB14TVihEpeYTvisD7XGxmZve7dmkiN-GzU,1268
44
+ praisonaiagents-0.0.90.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ praisonaiagents-0.0.90.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
46
+ praisonaiagents-0.0.90.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5