praisonaiagents 0.0.29__py3-none-any.whl → 0.0.53__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.
- praisonaiagents/__init__.py +4 -2
- praisonaiagents/agent/agent.py +679 -235
- praisonaiagents/agents/agents.py +169 -34
- praisonaiagents/knowledge/__init__.py +8 -0
- praisonaiagents/knowledge/chunking.py +182 -0
- praisonaiagents/knowledge/knowledge.py +321 -0
- praisonaiagents/llm/__init__.py +20 -0
- praisonaiagents/llm/llm.py +1023 -0
- praisonaiagents/main.py +46 -9
- praisonaiagents/memory/memory.py +6 -3
- praisonaiagents/process/process.py +206 -90
- praisonaiagents/task/task.py +104 -4
- praisonaiagents/tools/pandas_tools.py +3 -0
- praisonaiagents/tools/yfinance_tools.py +9 -1
- praisonaiagents-0.0.53.dist-info/METADATA +22 -0
- {praisonaiagents-0.0.29.dist-info → praisonaiagents-0.0.53.dist-info}/RECORD +18 -13
- praisonaiagents-0.0.29.dist-info/METADATA +0 -10
- {praisonaiagents-0.0.29.dist-info → praisonaiagents-0.0.53.dist-info}/WHEEL +0 -0
- {praisonaiagents-0.0.29.dist-info → praisonaiagents-0.0.53.dist-info}/top_level.txt +0 -0
praisonaiagents/task/task.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
import asyncio
|
3
|
-
from typing import List, Optional, Dict, Any, Type, Callable, Union, Coroutine
|
3
|
+
from typing import List, Optional, Dict, Any, Type, Callable, Union, Coroutine, Literal
|
4
4
|
from pydantic import BaseModel
|
5
5
|
from ..main import TaskOutput
|
6
6
|
from ..agent.agent import Agent
|
@@ -19,7 +19,7 @@ class Task:
|
|
19
19
|
agent: Optional[Agent] = None,
|
20
20
|
name: Optional[str] = None,
|
21
21
|
tools: Optional[List[Any]] = None,
|
22
|
-
context: Optional[List[
|
22
|
+
context: Optional[List[Union[str, List, 'Task']]] = None,
|
23
23
|
async_execution: Optional[bool] = False,
|
24
24
|
config: Optional[Dict[str, Any]] = None,
|
25
25
|
output_file: Optional[str] = None,
|
@@ -37,8 +37,21 @@ class Task:
|
|
37
37
|
is_start: bool = False,
|
38
38
|
loop_state: Optional[Dict[str, Union[str, int]]] = None,
|
39
39
|
memory=None,
|
40
|
-
quality_check=True
|
40
|
+
quality_check=True,
|
41
|
+
input_file: Optional[str] = None
|
41
42
|
):
|
43
|
+
# Add check if memory config is provided
|
44
|
+
if memory is not None or (config and config.get('memory_config')):
|
45
|
+
try:
|
46
|
+
from ..memory.memory import Memory
|
47
|
+
MEMORY_AVAILABLE = True
|
48
|
+
except ImportError:
|
49
|
+
raise ImportError(
|
50
|
+
"Memory features requested in Task but memory dependencies not installed. "
|
51
|
+
"Please install with: pip install \"praisonaiagents[memory]\""
|
52
|
+
)
|
53
|
+
|
54
|
+
self.input_file = input_file
|
42
55
|
self.id = str(uuid.uuid4()) if id is None else str(id)
|
43
56
|
self.name = name
|
44
57
|
self.description = description
|
@@ -83,6 +96,47 @@ class Task:
|
|
83
96
|
# Track previous tasks based on next_tasks relationships
|
84
97
|
self.previous_tasks = []
|
85
98
|
|
99
|
+
# If task_type="decision" and output_pydantic is not set
|
100
|
+
if self.task_type == "decision" and not self.output_pydantic:
|
101
|
+
from pydantic import BaseModel
|
102
|
+
from typing import Literal
|
103
|
+
|
104
|
+
# Gather condition keys for the "decision" field
|
105
|
+
condition_keys = list(self.condition.keys())
|
106
|
+
if not condition_keys:
|
107
|
+
# Fall back to placeholders if nothing is specified
|
108
|
+
condition_keys = ["next_task", "exit"]
|
109
|
+
|
110
|
+
# Create a dynamic literal type from condition keys
|
111
|
+
DecisionLiteral = Literal.__getitem__(tuple(condition_keys))
|
112
|
+
|
113
|
+
class DecisionModel(BaseModel):
|
114
|
+
response: str
|
115
|
+
decision: DecisionLiteral
|
116
|
+
|
117
|
+
self.output_pydantic = DecisionModel
|
118
|
+
|
119
|
+
# If task_type="loop" and output_pydantic is not set
|
120
|
+
if self.task_type == "loop" and not self.output_pydantic:
|
121
|
+
from pydantic import BaseModel
|
122
|
+
from typing import Literal
|
123
|
+
|
124
|
+
# Gather condition keys for the "decision" field
|
125
|
+
condition_keys = list(self.condition.keys())
|
126
|
+
if not condition_keys:
|
127
|
+
# Fall back to placeholders if nothing is specified
|
128
|
+
condition_keys = ["next_item", "exit"]
|
129
|
+
|
130
|
+
# Create a dynamic literal type
|
131
|
+
LoopLiteral = Literal.__getitem__(tuple(condition_keys))
|
132
|
+
|
133
|
+
class LoopModel(BaseModel):
|
134
|
+
response: str
|
135
|
+
decision: LoopLiteral
|
136
|
+
loop_id: str # Additional field for loop
|
137
|
+
|
138
|
+
self.output_pydantic = LoopModel
|
139
|
+
|
86
140
|
def __str__(self):
|
87
141
|
return f"Task(name='{self.name if self.name else 'None'}', description='{self.description}', agent='{self.agent.name if self.agent else 'None'}', status='{self.status}')"
|
88
142
|
|
@@ -219,4 +273,50 @@ class Task:
|
|
219
273
|
self.callback(task_output)
|
220
274
|
except Exception as e:
|
221
275
|
logger.error(f"Task {self.id}: Failed to execute callback: {e}")
|
222
|
-
logger.exception(e)
|
276
|
+
logger.exception(e)
|
277
|
+
|
278
|
+
task_prompt = f"""
|
279
|
+
You need to do the following task: {self.description}.
|
280
|
+
Expected Output: {self.expected_output}.
|
281
|
+
"""
|
282
|
+
if self.context:
|
283
|
+
context_results = [] # Use list to avoid duplicates
|
284
|
+
for context_item in self.context:
|
285
|
+
if isinstance(context_item, str):
|
286
|
+
context_results.append(f"Input Content:\n{context_item}")
|
287
|
+
elif isinstance(context_item, list):
|
288
|
+
context_results.append(f"Input Content: {' '.join(str(x) for x in context_item)}")
|
289
|
+
elif hasattr(context_item, 'result'): # Task object
|
290
|
+
if context_item.result:
|
291
|
+
context_results.append(
|
292
|
+
f"Result of previous task {context_item.name if context_item.name else context_item.description}:\n{context_item.result.raw}"
|
293
|
+
)
|
294
|
+
else:
|
295
|
+
context_results.append(
|
296
|
+
f"Previous task {context_item.name if context_item.name else context_item.description} has no result yet."
|
297
|
+
)
|
298
|
+
|
299
|
+
# Join unique context results
|
300
|
+
unique_contexts = list(dict.fromkeys(context_results)) # Remove duplicates
|
301
|
+
task_prompt += f"""
|
302
|
+
Context:
|
303
|
+
|
304
|
+
{' '.join(unique_contexts)}
|
305
|
+
"""
|
306
|
+
|
307
|
+
def execute_callback_sync(self, task_output: TaskOutput) -> None:
|
308
|
+
"""
|
309
|
+
Synchronous wrapper to ensure that execute_callback is awaited,
|
310
|
+
preventing 'Task was destroyed but pending!' warnings if called
|
311
|
+
from non-async code.
|
312
|
+
"""
|
313
|
+
import asyncio
|
314
|
+
try:
|
315
|
+
loop = asyncio.get_running_loop()
|
316
|
+
if loop.is_running():
|
317
|
+
loop.create_task(self.execute_callback(task_output))
|
318
|
+
else:
|
319
|
+
loop.run_until_complete(self.execute_callback(task_output))
|
320
|
+
except RuntimeError:
|
321
|
+
# If no loop is running in this context
|
322
|
+
asyncio.run(self.execute_callback(task_output))
|
@@ -160,6 +160,9 @@ class PandasTools:
|
|
160
160
|
Dict: Summary statistics and information
|
161
161
|
"""
|
162
162
|
try:
|
163
|
+
if not isinstance(df, pd.DataFrame):
|
164
|
+
raise TypeError(f"Expected pandas DataFrame, got {type(df).__name__}")
|
165
|
+
|
163
166
|
numeric_summary = df.describe().to_dict()
|
164
167
|
# Convert numpy types to native Python types
|
165
168
|
for col in numeric_summary:
|
@@ -145,7 +145,15 @@ class YFinanceTools:
|
|
145
145
|
return [{"error": "yfinance package not available"}]
|
146
146
|
|
147
147
|
hist = ticker.history(period=period, interval=interval, start=start, end=end)
|
148
|
-
|
148
|
+
data = hist.reset_index().to_dict('records')
|
149
|
+
|
150
|
+
# Convert timestamps to ISO format strings
|
151
|
+
for record in data:
|
152
|
+
if 'Date' in record and hasattr(record['Date'], 'isoformat'):
|
153
|
+
record['Date'] = record['Date'].isoformat()
|
154
|
+
if 'Datetime' in record and hasattr(record['Datetime'], 'isoformat'):
|
155
|
+
record['Datetime'] = record['Datetime'].isoformat()
|
156
|
+
return data
|
149
157
|
except Exception as e:
|
150
158
|
error_msg = f"Error fetching historical data: {str(e)}"
|
151
159
|
logging.error(error_msg)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: praisonaiagents
|
3
|
+
Version: 0.0.53
|
4
|
+
Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
|
5
|
+
Author: Mervin Praison
|
6
|
+
Requires-Dist: pydantic
|
7
|
+
Requires-Dist: rich
|
8
|
+
Requires-Dist: openai
|
9
|
+
Provides-Extra: memory
|
10
|
+
Requires-Dist: chromadb>=0.5.23; extra == "memory"
|
11
|
+
Provides-Extra: knowledge
|
12
|
+
Requires-Dist: mem0ai>=0.1.0; extra == "knowledge"
|
13
|
+
Requires-Dist: chromadb==0.5.23; extra == "knowledge"
|
14
|
+
Requires-Dist: markitdown; extra == "knowledge"
|
15
|
+
Requires-Dist: chonkie; extra == "knowledge"
|
16
|
+
Provides-Extra: llm
|
17
|
+
Requires-Dist: litellm>=1.50.0; extra == "llm"
|
18
|
+
Requires-Dist: pydantic>=2.4.2; extra == "llm"
|
19
|
+
Provides-Extra: all
|
20
|
+
Requires-Dist: praisonaiagents[memory]; extra == "all"
|
21
|
+
Requires-Dist: praisonaiagents[knowledge]; extra == "all"
|
22
|
+
Requires-Dist: praisonaiagents[llm]; extra == "all"
|
@@ -1,15 +1,20 @@
|
|
1
|
-
praisonaiagents/__init__.py,sha256=
|
2
|
-
praisonaiagents/main.py,sha256=
|
1
|
+
praisonaiagents/__init__.py,sha256=JtPibbmeFv3meIb3vkKjckB0p7m-Vqt2RYPwOH8P41k,1228
|
2
|
+
praisonaiagents/main.py,sha256=0kB9gn9meXtr4EIrdgA2lAioKIHCRJ61audsGDwuTm4,14428
|
3
3
|
praisonaiagents/agent/__init__.py,sha256=sKO8wGEXvtCrvV1e834r1Okv0XAqAxqZCqz6hKLiTvA,79
|
4
|
-
praisonaiagents/agent/agent.py,sha256=
|
4
|
+
praisonaiagents/agent/agent.py,sha256=du4wbXOWr4TKeTdlHxfqtq3O7NoQNh5P94cBVF6Nj_M,54417
|
5
5
|
praisonaiagents/agents/__init__.py,sha256=_1d6Pqyk9EoBSo7E68sKyd1jDRlN1vxvVIRpoMc0Jcw,168
|
6
|
-
praisonaiagents/agents/agents.py,sha256=
|
6
|
+
praisonaiagents/agents/agents.py,sha256=94YPQl-hl-EPY6-Xk2Rj9wlIs9YtiLQbsutSOXWX8QI,36156
|
7
7
|
praisonaiagents/agents/autoagents.py,sha256=bjC2O5oZmoJItJXIMPTWc2lsp_AJC9tMiTQOal2hwPA,13532
|
8
|
-
praisonaiagents/
|
8
|
+
praisonaiagents/knowledge/__init__.py,sha256=xL1Eh-a3xsHyIcU4foOWF-JdWYIYBALJH9bge0Ujuto,246
|
9
|
+
praisonaiagents/knowledge/chunking.py,sha256=FzoNY0q8MkvG4gADqk4JcRhmH3lcEHbRdonDgitQa30,6624
|
10
|
+
praisonaiagents/knowledge/knowledge.py,sha256=fQNREDiwdoisfIxJBLVkteXgq_8Gbypfc3UaZbxf5QY,13210
|
11
|
+
praisonaiagents/llm/__init__.py,sha256=ttPQQJQq6Tah-0updoEXDZFKWtJAM93rBWRoIgxRWO8,689
|
12
|
+
praisonaiagents/llm/llm.py,sha256=S-9GBQcOoXQ7mzT119N7k6QzqwPIHSrXqbzluYzGntQ,49533
|
13
|
+
praisonaiagents/memory/memory.py,sha256=I8dOTkrl1i-GgQbDcrFOsSruzJ7MiI6Ys37DK27wrUs,35537
|
9
14
|
praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
|
10
|
-
praisonaiagents/process/process.py,sha256=
|
15
|
+
praisonaiagents/process/process.py,sha256=_1Nk37kOYakPaUWAJff86rP0ENyykXqMnhTp8E0efuE,30802
|
11
16
|
praisonaiagents/task/__init__.py,sha256=VL5hXVmyGjINb34AalxpBMl-YW9m5EDcRkMTKkSSl7c,80
|
12
|
-
praisonaiagents/task/task.py,sha256=
|
17
|
+
praisonaiagents/task/task.py,sha256=ikFjzNm4WPYONSLtWA3uDGNIUx_TvXTeU5SukWoC66E,14271
|
13
18
|
praisonaiagents/tools/__init__.py,sha256=-0lV5n5cG54vYW6REjXIfuJnCLKnfQIDlXsySCaPB9s,7347
|
14
19
|
praisonaiagents/tools/arxiv_tools.py,sha256=1stb31zTjLTon4jCnpZG5de9rKc9QWgC0leLegvPXWo,10528
|
15
20
|
praisonaiagents/tools/calculator_tools.py,sha256=S1xPT74Geurvjm52QMMIG29zDXVEWJmM6nmyY7yF298,9571
|
@@ -20,7 +25,7 @@ praisonaiagents/tools/excel_tools.py,sha256=e2HqcwnyBueOyss0xEKxff3zB4w4sNWCOMXv
|
|
20
25
|
praisonaiagents/tools/file_tools.py,sha256=KRskI9q8up3sHaLQSaIGtvpl1brq419Up6YvB9QzSoI,8807
|
21
26
|
praisonaiagents/tools/json_tools.py,sha256=ApUYNuQ1qnbmYNCxSlx6Tth_H1yo8mhWtZ7Rr2WS6C4,16507
|
22
27
|
praisonaiagents/tools/newspaper_tools.py,sha256=NyhojNPeyULBGcAWGOT1X70qVkh3FgZrpH-S7PEmrwI,12667
|
23
|
-
praisonaiagents/tools/pandas_tools.py,sha256=
|
28
|
+
praisonaiagents/tools/pandas_tools.py,sha256=yzCeY4jetKrFIRA15Tr5OQ5d94T8DaSpzglx2UiWfPs,11092
|
24
29
|
praisonaiagents/tools/python_tools.py,sha256=ByBpESi5Vk2ivpihav9AQeqf95K_D4qqINYN1q-q0bA,13428
|
25
30
|
praisonaiagents/tools/shell_tools.py,sha256=P3fSrfOw71CGcrPwdPOA9Fr6Bgt_CAC71bUjCyvZCN8,9301
|
26
31
|
praisonaiagents/tools/spider_tools.py,sha256=lrZnT1V1BC46We-AzBrDB1Ryifr3KKGmYNntMsScU7w,15094
|
@@ -29,8 +34,8 @@ praisonaiagents/tools/tools.py,sha256=TK5njOmDSpMlyBnbeBzNSlnzXWlnNaTpVqkFPhkMAr
|
|
29
34
|
praisonaiagents/tools/wikipedia_tools.py,sha256=pGko-f33wqXgxJTv8db7TbizY5XnzBQRkNdq_GsplvI,9465
|
30
35
|
praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxNMMs1A,17122
|
31
36
|
praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
|
32
|
-
praisonaiagents/tools/yfinance_tools.py,sha256=
|
33
|
-
praisonaiagents-0.0.
|
34
|
-
praisonaiagents-0.0.
|
35
|
-
praisonaiagents-0.0.
|
36
|
-
praisonaiagents-0.0.
|
37
|
+
praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
|
38
|
+
praisonaiagents-0.0.53.dist-info/METADATA,sha256=DAmi3nqq0kER9xJhFPZ8e3JC_TCeSdH2zKzrrZyZCZ4,830
|
39
|
+
praisonaiagents-0.0.53.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
40
|
+
praisonaiagents-0.0.53.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
|
41
|
+
praisonaiagents-0.0.53.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: praisonaiagents
|
3
|
-
Version: 0.0.29
|
4
|
-
Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
|
5
|
-
Author: Mervin Praison
|
6
|
-
Requires-Dist: pydantic
|
7
|
-
Requires-Dist: rich
|
8
|
-
Requires-Dist: openai
|
9
|
-
Provides-Extra: memory
|
10
|
-
Requires-Dist: chromadb>=0.6.0; extra == "memory"
|
File without changes
|
File without changes
|