praisonaiagents 0.0.37__py3-none-any.whl → 0.0.39__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/knowledge/knowledge.py +49 -15
- {praisonaiagents-0.0.37.dist-info → praisonaiagents-0.0.39.dist-info}/METADATA +1 -1
- {praisonaiagents-0.0.37.dist-info → praisonaiagents-0.0.39.dist-info}/RECORD +5 -5
- {praisonaiagents-0.0.37.dist-info → praisonaiagents-0.0.39.dist-info}/WHEEL +0 -0
- {praisonaiagents-0.0.37.dist-info → praisonaiagents-0.0.39.dist-info}/top_level.txt +0 -0
@@ -4,6 +4,7 @@ import uuid
|
|
4
4
|
import time
|
5
5
|
from .chunking import Chunking
|
6
6
|
from functools import cached_property
|
7
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, TaskProgressColumn
|
7
8
|
|
8
9
|
logger = logging.getLogger(__name__)
|
9
10
|
|
@@ -43,9 +44,28 @@ class CustomMemory:
|
|
43
44
|
}]
|
44
45
|
|
45
46
|
class Knowledge:
|
46
|
-
def __init__(self, config=None):
|
47
|
+
def __init__(self, config=None, verbose=None):
|
47
48
|
self._config = config
|
49
|
+
self._verbose = verbose or 0
|
48
50
|
os.environ['ANONYMIZED_TELEMETRY'] = 'False' # Chromadb
|
51
|
+
|
52
|
+
# Configure logging levels based on verbose setting
|
53
|
+
if not self._verbose:
|
54
|
+
# Suppress logs from all relevant dependencies
|
55
|
+
for logger_name in [
|
56
|
+
'mem0',
|
57
|
+
'chromadb',
|
58
|
+
'local_persistent_hnsw',
|
59
|
+
'_client',
|
60
|
+
'main'
|
61
|
+
]:
|
62
|
+
logging.getLogger(logger_name).setLevel(logging.WARNING)
|
63
|
+
|
64
|
+
# Disable OpenAI API request logging
|
65
|
+
logging.getLogger('openai').setLevel(logging.WARNING)
|
66
|
+
|
67
|
+
# Set root logger to warning to catch any uncategorized logs
|
68
|
+
logging.getLogger().setLevel(logging.WARNING)
|
49
69
|
|
50
70
|
@cached_property
|
51
71
|
def _deps(self):
|
@@ -121,14 +141,17 @@ class Knowledge:
|
|
121
141
|
chunk_overlap=50
|
122
142
|
)
|
123
143
|
|
144
|
+
def _log(self, message, level=2):
|
145
|
+
"""Internal logging helper"""
|
146
|
+
if self._verbose and self._verbose >= level:
|
147
|
+
logger.info(message)
|
148
|
+
|
124
149
|
def store(self, content, user_id=None, agent_id=None, run_id=None, metadata=None):
|
125
150
|
"""Store a memory."""
|
126
151
|
try:
|
127
|
-
# Process content to match expected format
|
128
152
|
if isinstance(content, str):
|
129
|
-
# Check if content is actually a file path
|
130
153
|
if any(content.lower().endswith(ext) for ext in ['.pdf', '.doc', '.docx', '.txt']):
|
131
|
-
|
154
|
+
self._log(f"Content appears to be a file path, processing file: {content}")
|
132
155
|
return self.add(content, user_id=user_id, agent_id=agent_id, run_id=run_id, metadata=metadata)
|
133
156
|
|
134
157
|
content = content.strip()
|
@@ -136,7 +159,7 @@ class Knowledge:
|
|
136
159
|
return []
|
137
160
|
|
138
161
|
result = self.memory.add(content, user_id=user_id, agent_id=agent_id, run_id=run_id, metadata=metadata)
|
139
|
-
|
162
|
+
self._log(f"Store operation result: {result}")
|
140
163
|
return result
|
141
164
|
except Exception as e:
|
142
165
|
logger.error(f"Error storing content: {str(e)}")
|
@@ -210,8 +233,7 @@ class Knowledge:
|
|
210
233
|
|
211
234
|
# Check if input is URL
|
212
235
|
if isinstance(input_path, str) and (input_path.startswith('http://') or input_path.startswith('https://')):
|
213
|
-
|
214
|
-
# TODO: Implement URL handling
|
236
|
+
self._log(f"Processing URL: {input_path}")
|
215
237
|
raise NotImplementedError("URL processing not yet implemented")
|
216
238
|
|
217
239
|
# Check if input ends with any supported extension
|
@@ -220,7 +242,7 @@ class Knowledge:
|
|
220
242
|
for ext in (exts if isinstance(exts, tuple) else (exts,)))
|
221
243
|
|
222
244
|
if is_supported_file:
|
223
|
-
|
245
|
+
self._log(f"Processing as file path: {input_path}")
|
224
246
|
if not os.path.exists(input_path):
|
225
247
|
logger.error(f"File not found: {input_path}")
|
226
248
|
raise FileNotFoundError(f"File not found: {input_path}")
|
@@ -253,14 +275,26 @@ class Knowledge:
|
|
253
275
|
# Treat as raw text content only if no file extension
|
254
276
|
memories = [self.normalize_content(input_path)]
|
255
277
|
|
256
|
-
#
|
278
|
+
# Create progress display
|
279
|
+
progress = Progress(
|
280
|
+
SpinnerColumn(),
|
281
|
+
TextColumn("[progress.description]{task.description}"),
|
282
|
+
BarColumn(),
|
283
|
+
TaskProgressColumn(),
|
284
|
+
transient=True
|
285
|
+
)
|
286
|
+
|
287
|
+
# Store memories with progress bar
|
257
288
|
all_results = []
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
289
|
+
with progress:
|
290
|
+
store_task = progress.add_task(f"Adding to Knowledge from {os.path.basename(input_path)}", total=len(memories))
|
291
|
+
for memory in memories:
|
292
|
+
if memory:
|
293
|
+
memory_result = self.store(memory, user_id=user_id, agent_id=agent_id,
|
294
|
+
run_id=run_id, metadata=metadata)
|
295
|
+
if memory_result:
|
296
|
+
all_results.extend(memory_result.get('results', []))
|
297
|
+
progress.advance(store_task)
|
264
298
|
|
265
299
|
return {'results': all_results, 'relations': []}
|
266
300
|
|
@@ -7,7 +7,7 @@ praisonaiagents/agents/agents.py,sha256=M-nR53A7Qcz_pJ-gyNc4xgM13Nhof7oM-5hXWzr8
|
|
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=
|
10
|
+
praisonaiagents/knowledge/knowledge.py,sha256=dJd8WuFV3w-zWaSAcT21PcXGRIZZc6YxBsJZDfmZNrk,12358
|
11
11
|
praisonaiagents/memory/memory.py,sha256=ZxqSpOUxk9jeTKGW0ZiTifC0uZtym-EZILP3kuOOKkU,35626
|
12
12
|
praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
|
13
13
|
praisonaiagents/process/process.py,sha256=uSudOFI1ZlGM_nbT8qHD4iIP3y5Ygu8V-izLot2te70,26316
|
@@ -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.39.dist-info/METADATA,sha256=nfUgMS-EXpJn1Aee7bNdYcDq_Oxgkcbe-W3DrcCEWLw,664
|
37
|
+
praisonaiagents-0.0.39.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
38
|
+
praisonaiagents-0.0.39.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
|
39
|
+
praisonaiagents-0.0.39.dist-info/RECORD,,
|
File without changes
|
File without changes
|