praisonaiagents 0.0.44__py3-none-any.whl → 0.0.46__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 +0 -2
- praisonaiagents/agent/agent.py +11 -0
- praisonaiagents/agents/agents.py +48 -1
- praisonaiagents/knowledge/knowledge.py +29 -11
- praisonaiagents/memory/memory.py +1 -1
- praisonaiagents/task/task.py +11 -0
- {praisonaiagents-0.0.44.dist-info → praisonaiagents-0.0.46.dist-info}/METADATA +1 -1
- {praisonaiagents-0.0.44.dist-info → praisonaiagents-0.0.46.dist-info}/RECORD +10 -10
- {praisonaiagents-0.0.44.dist-info → praisonaiagents-0.0.46.dist-info}/WHEEL +0 -0
- {praisonaiagents-0.0.44.dist-info → praisonaiagents-0.0.46.dist-info}/top_level.txt +0 -0
praisonaiagents/__init__.py
CHANGED
@@ -9,7 +9,6 @@ from .tools.tools import Tools
|
|
9
9
|
from .agents.autoagents import AutoAgents
|
10
10
|
from .knowledge.knowledge import Knowledge
|
11
11
|
from .knowledge.chunking import Chunking
|
12
|
-
from .memory.memory import Memory
|
13
12
|
from .main import (
|
14
13
|
TaskOutput,
|
15
14
|
ReflectionOutput,
|
@@ -38,7 +37,6 @@ __all__ = [
|
|
38
37
|
'TaskOutput',
|
39
38
|
'ReflectionOutput',
|
40
39
|
'AutoAgents',
|
41
|
-
'Memory',
|
42
40
|
'display_interaction',
|
43
41
|
'display_self_reflection',
|
44
42
|
'display_instruction',
|
praisonaiagents/agent/agent.py
CHANGED
@@ -192,6 +192,17 @@ class Agent:
|
|
192
192
|
reflect_llm: Optional[str] = None,
|
193
193
|
user_id: Optional[str] = None
|
194
194
|
):
|
195
|
+
# Add check at start if memory is requested
|
196
|
+
if memory is not None:
|
197
|
+
try:
|
198
|
+
from ..memory.memory import Memory
|
199
|
+
MEMORY_AVAILABLE = True
|
200
|
+
except ImportError:
|
201
|
+
raise ImportError(
|
202
|
+
"Memory features requested in Agent but memory dependencies not installed. "
|
203
|
+
"Please install with: pip install \"praisonaiagents[memory]\""
|
204
|
+
)
|
205
|
+
|
195
206
|
# Handle backward compatibility for required fields
|
196
207
|
if all(x is None for x in [name, role, goal, backstory, instructions]):
|
197
208
|
raise ValueError("At least one of name, role, goal, backstory, or instructions must be provided")
|
praisonaiagents/agents/agents.py
CHANGED
@@ -46,11 +46,22 @@ def process_video(video_path: str, seconds_per_frame=2):
|
|
46
46
|
|
47
47
|
class PraisonAIAgents:
|
48
48
|
def __init__(self, agents, tasks=None, verbose=0, completion_checker=None, max_retries=5, process="sequential", manager_llm=None, memory=False, memory_config=None, embedder=None, user_id=None, max_iter=10):
|
49
|
+
# Add check at the start if memory is requested
|
50
|
+
if memory:
|
51
|
+
try:
|
52
|
+
from ..memory.memory import Memory
|
53
|
+
MEMORY_AVAILABLE = True
|
54
|
+
except ImportError:
|
55
|
+
raise ImportError(
|
56
|
+
"Memory features requested but memory dependencies not installed. "
|
57
|
+
"Please install with: pip install \"praisonaiagents[memory]\""
|
58
|
+
)
|
59
|
+
|
49
60
|
if not agents:
|
50
61
|
raise ValueError("At least one agent must be provided")
|
51
62
|
|
52
63
|
self.run_id = str(uuid.uuid4()) # Auto-generate run_id
|
53
|
-
self.user_id = user_id # Optional user_id
|
64
|
+
self.user_id = user_id or "praison" # Optional user_id
|
54
65
|
self.max_iter = max_iter # Add max_iter parameter
|
55
66
|
|
56
67
|
# Pass user_id to each agent
|
@@ -245,6 +256,24 @@ Expected Output: {task.expected_output}.
|
|
245
256
|
context_results.append(
|
246
257
|
f"Previous task {context_item.name if context_item.name else context_item.description} has no result yet."
|
247
258
|
)
|
259
|
+
elif isinstance(context_item, dict) and "vector_store" in context_item:
|
260
|
+
from ..knowledge.knowledge import Knowledge
|
261
|
+
try:
|
262
|
+
# Handle both string and dict configs
|
263
|
+
cfg = context_item["vector_store"]
|
264
|
+
if isinstance(cfg, str):
|
265
|
+
cfg = json.loads(cfg)
|
266
|
+
|
267
|
+
knowledge = Knowledge(config={"vector_store": cfg}, verbose=self.verbose)
|
268
|
+
|
269
|
+
# Only use user_id as filter
|
270
|
+
db_results = knowledge.search(
|
271
|
+
task.description,
|
272
|
+
user_id=self.user_id if self.user_id else None
|
273
|
+
)
|
274
|
+
context_results.append(f"[DB Context]: {str(db_results)}")
|
275
|
+
except Exception as e:
|
276
|
+
context_results.append(f"[Vector DB Error]: {e}")
|
248
277
|
|
249
278
|
# Join unique context results
|
250
279
|
unique_contexts = list(dict.fromkeys(context_results)) # Remove duplicates
|
@@ -523,6 +552,24 @@ Expected Output: {task.expected_output}.
|
|
523
552
|
context_results.append(
|
524
553
|
f"Previous task {context_item.name if context_item.name else context_item.description} has no result yet."
|
525
554
|
)
|
555
|
+
elif isinstance(context_item, dict) and "vector_store" in context_item:
|
556
|
+
from ..knowledge.knowledge import Knowledge
|
557
|
+
try:
|
558
|
+
# Handle both string and dict configs
|
559
|
+
cfg = context_item["vector_store"]
|
560
|
+
if isinstance(cfg, str):
|
561
|
+
cfg = json.loads(cfg)
|
562
|
+
|
563
|
+
knowledge = Knowledge(config={"vector_store": cfg}, verbose=self.verbose)
|
564
|
+
|
565
|
+
# Only use user_id as filter
|
566
|
+
db_results = knowledge.search(
|
567
|
+
task.description,
|
568
|
+
user_id=self.user_id if self.user_id else None
|
569
|
+
)
|
570
|
+
context_results.append(f"[DB Context]: {str(db_results)}")
|
571
|
+
except Exception as e:
|
572
|
+
context_results.append(f"[Vector DB Error]: {e}")
|
526
573
|
|
527
574
|
# Join unique context results
|
528
575
|
unique_contexts = list(dict.fromkeys(context_results)) # Remove duplicates
|
@@ -84,8 +84,8 @@ class Knowledge:
|
|
84
84
|
|
85
85
|
@cached_property
|
86
86
|
def config(self):
|
87
|
-
# Generate unique collection name for each instance
|
88
|
-
|
87
|
+
# Generate unique collection name for each instance (only if not provided in config)
|
88
|
+
default_collection = f"test_{int(time.time())}_{str(uuid.uuid4())[:8]}"
|
89
89
|
persist_dir = ".praison"
|
90
90
|
|
91
91
|
# Create persistent client config
|
@@ -93,9 +93,11 @@ class Knowledge:
|
|
93
93
|
"vector_store": {
|
94
94
|
"provider": "chroma",
|
95
95
|
"config": {
|
96
|
-
"collection_name":
|
96
|
+
"collection_name": default_collection,
|
97
97
|
"path": persist_dir,
|
98
|
-
"client": self._deps['chromadb'].PersistentClient(path=persist_dir)
|
98
|
+
"client": self._deps['chromadb'].PersistentClient(path=persist_dir),
|
99
|
+
"host": None,
|
100
|
+
"port": None
|
99
101
|
}
|
100
102
|
},
|
101
103
|
"version": "v1.1",
|
@@ -104,13 +106,29 @@ class Knowledge:
|
|
104
106
|
|
105
107
|
# If config is provided, merge it with base config
|
106
108
|
if self._config:
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
# Merge version if provided
|
110
|
+
if "version" in self._config:
|
111
|
+
base_config["version"] = self._config["version"]
|
112
|
+
|
113
|
+
# Merge vector_store config
|
114
|
+
if "vector_store" in self._config:
|
115
|
+
if "provider" in self._config["vector_store"]:
|
116
|
+
base_config["vector_store"]["provider"] = self._config["vector_store"]["provider"]
|
117
|
+
|
118
|
+
if "config" in self._config["vector_store"]:
|
119
|
+
config_copy = self._config["vector_store"]["config"].copy()
|
120
|
+
# Only exclude client as it's managed internally
|
121
|
+
if "client" in config_copy:
|
122
|
+
del config_copy["client"]
|
123
|
+
base_config["vector_store"]["config"].update(config_copy)
|
124
|
+
|
125
|
+
# Merge embedder config if provided
|
126
|
+
if "embedder" in self._config:
|
127
|
+
base_config["embedder"] = self._config["embedder"]
|
128
|
+
|
129
|
+
# Merge llm config if provided
|
130
|
+
if "llm" in self._config:
|
131
|
+
base_config["llm"] = self._config["llm"]
|
114
132
|
return base_config
|
115
133
|
|
116
134
|
@cached_property
|
praisonaiagents/memory/memory.py
CHANGED
praisonaiagents/task/task.py
CHANGED
@@ -40,6 +40,17 @@ class Task:
|
|
40
40
|
quality_check=True,
|
41
41
|
input_file: Optional[str] = None
|
42
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
|
+
|
43
54
|
self.input_file = input_file
|
44
55
|
self.id = str(uuid.uuid4()) if id is None else str(id)
|
45
56
|
self.name = name
|
@@ -1,18 +1,18 @@
|
|
1
|
-
praisonaiagents/__init__.py,sha256=
|
1
|
+
praisonaiagents/__init__.py,sha256=JtPibbmeFv3meIb3vkKjckB0p7m-Vqt2RYPwOH8P41k,1228
|
2
2
|
praisonaiagents/main.py,sha256=wcFooRmCY38wtkSNFt6-nhZafgrHotCZE0S6U8IWgUY,14093
|
3
3
|
praisonaiagents/agent/__init__.py,sha256=sKO8wGEXvtCrvV1e834r1Okv0XAqAxqZCqz6hKLiTvA,79
|
4
|
-
praisonaiagents/agent/agent.py,sha256=
|
4
|
+
praisonaiagents/agent/agent.py,sha256=0738lTpJzNcm0HlWLqv--q3CfklBJkRJcZ4twTBXtSQ,38293
|
5
5
|
praisonaiagents/agents/__init__.py,sha256=_1d6Pqyk9EoBSo7E68sKyd1jDRlN1vxvVIRpoMc0Jcw,168
|
6
|
-
praisonaiagents/agents/agents.py,sha256=
|
6
|
+
praisonaiagents/agents/agents.py,sha256=kGgL9IAHuatwOkBF-4mtSpLCLgiVHgWnMh1R2iqdKVg,35956
|
7
7
|
praisonaiagents/agents/autoagents.py,sha256=bjC2O5oZmoJItJXIMPTWc2lsp_AJC9tMiTQOal2hwPA,13532
|
8
8
|
praisonaiagents/knowledge/__init__.py,sha256=xL1Eh-a3xsHyIcU4foOWF-JdWYIYBALJH9bge0Ujuto,246
|
9
9
|
praisonaiagents/knowledge/chunking.py,sha256=FzoNY0q8MkvG4gADqk4JcRhmH3lcEHbRdonDgitQa30,6624
|
10
|
-
praisonaiagents/knowledge/knowledge.py,sha256=
|
11
|
-
praisonaiagents/memory/memory.py,sha256=
|
10
|
+
praisonaiagents/knowledge/knowledge.py,sha256=fQNREDiwdoisfIxJBLVkteXgq_8Gbypfc3UaZbxf5QY,13210
|
11
|
+
praisonaiagents/memory/memory.py,sha256=I8dOTkrl1i-GgQbDcrFOsSruzJ7MiI6Ys37DK27wrUs,35537
|
12
12
|
praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
|
13
13
|
praisonaiagents/process/process.py,sha256=_1Nk37kOYakPaUWAJff86rP0ENyykXqMnhTp8E0efuE,30802
|
14
14
|
praisonaiagents/task/__init__.py,sha256=VL5hXVmyGjINb34AalxpBMl-YW9m5EDcRkMTKkSSl7c,80
|
15
|
-
praisonaiagents/task/task.py,sha256=
|
15
|
+
praisonaiagents/task/task.py,sha256=YKoUOyIBQflOSCO4nuSi6sL-s2-Awujjs44qNqiUETI,13582
|
16
16
|
praisonaiagents/tools/__init__.py,sha256=-0lV5n5cG54vYW6REjXIfuJnCLKnfQIDlXsySCaPB9s,7347
|
17
17
|
praisonaiagents/tools/arxiv_tools.py,sha256=1stb31zTjLTon4jCnpZG5de9rKc9QWgC0leLegvPXWo,10528
|
18
18
|
praisonaiagents/tools/calculator_tools.py,sha256=S1xPT74Geurvjm52QMMIG29zDXVEWJmM6nmyY7yF298,9571
|
@@ -33,7 +33,7 @@ praisonaiagents/tools/wikipedia_tools.py,sha256=pGko-f33wqXgxJTv8db7TbizY5XnzBQR
|
|
33
33
|
praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxNMMs1A,17122
|
34
34
|
praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
|
35
35
|
praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
|
36
|
-
praisonaiagents-0.0.
|
37
|
-
praisonaiagents-0.0.
|
38
|
-
praisonaiagents-0.0.
|
39
|
-
praisonaiagents-0.0.
|
36
|
+
praisonaiagents-0.0.46.dist-info/METADATA,sha256=ZaFzUCxbw3uoF7jLfgeVymtirenVl2hwvd8ls579yMI,664
|
37
|
+
praisonaiagents-0.0.46.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
38
|
+
praisonaiagents-0.0.46.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
|
39
|
+
praisonaiagents-0.0.46.dist-info/RECORD,,
|
File without changes
|
File without changes
|