praisonaiagents 0.0.101__py3-none-any.whl → 0.0.102__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 +2 -0
- praisonaiagents/memory/memory.py +121 -45
- {praisonaiagents-0.0.101.dist-info → praisonaiagents-0.0.102.dist-info}/METADATA +1 -1
- {praisonaiagents-0.0.101.dist-info → praisonaiagents-0.0.102.dist-info}/RECORD +6 -6
- {praisonaiagents-0.0.101.dist-info → praisonaiagents-0.0.102.dist-info}/WHEEL +0 -0
- {praisonaiagents-0.0.101.dist-info → praisonaiagents-0.0.102.dist-info}/top_level.txt +0 -0
praisonaiagents/__init__.py
CHANGED
@@ -12,6 +12,7 @@ from .knowledge.knowledge import Knowledge
|
|
12
12
|
from .knowledge.chunking import Chunking
|
13
13
|
from .mcp.mcp import MCP
|
14
14
|
from .session import Session
|
15
|
+
from .memory.memory import Memory
|
15
16
|
from .guardrails import GuardrailResult, LLMGuardrail
|
16
17
|
from .main import (
|
17
18
|
TaskOutput,
|
@@ -43,6 +44,7 @@ __all__ = [
|
|
43
44
|
'ReflectionOutput',
|
44
45
|
'AutoAgents',
|
45
46
|
'Session',
|
47
|
+
'Memory',
|
46
48
|
'display_interaction',
|
47
49
|
'display_self_reflection',
|
48
50
|
'display_instruction',
|
praisonaiagents/memory/memory.py
CHANGED
@@ -29,6 +29,12 @@ try:
|
|
29
29
|
except ImportError:
|
30
30
|
OPENAI_AVAILABLE = False
|
31
31
|
|
32
|
+
try:
|
33
|
+
import litellm
|
34
|
+
LITELLM_AVAILABLE = True
|
35
|
+
except ImportError:
|
36
|
+
LITELLM_AVAILABLE = False
|
37
|
+
|
32
38
|
|
33
39
|
|
34
40
|
|
@@ -340,14 +346,28 @@ class Memory:
|
|
340
346
|
|
341
347
|
elif self.use_rag and hasattr(self, "chroma_col"):
|
342
348
|
try:
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
349
|
+
if LITELLM_AVAILABLE:
|
350
|
+
# Use LiteLLM for consistency with the rest of the codebase
|
351
|
+
import litellm
|
352
|
+
|
353
|
+
response = litellm.embedding(
|
354
|
+
model="text-embedding-3-small",
|
355
|
+
input=query
|
356
|
+
)
|
357
|
+
query_embedding = response.data[0]["embedding"]
|
358
|
+
elif OPENAI_AVAILABLE:
|
359
|
+
# Fallback to OpenAI client
|
360
|
+
from openai import OpenAI
|
361
|
+
client = OpenAI()
|
362
|
+
|
363
|
+
response = client.embeddings.create(
|
364
|
+
input=query,
|
365
|
+
model="text-embedding-3-small"
|
366
|
+
)
|
367
|
+
query_embedding = response.data[0].embedding
|
368
|
+
else:
|
369
|
+
self._log_verbose("Neither litellm nor openai available for embeddings", logging.WARNING)
|
370
|
+
return []
|
351
371
|
|
352
372
|
resp = self.chroma_col.query(
|
353
373
|
query_embeddings=[query_embedding],
|
@@ -464,19 +484,39 @@ class Memory:
|
|
464
484
|
# Store in vector database if enabled
|
465
485
|
if self.use_rag and hasattr(self, "chroma_col"):
|
466
486
|
try:
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
487
|
+
if LITELLM_AVAILABLE:
|
488
|
+
# Use LiteLLM for consistency with the rest of the codebase
|
489
|
+
import litellm
|
490
|
+
|
491
|
+
logger.info("Getting embeddings from LiteLLM...")
|
492
|
+
logger.debug(f"Embedding input text: {text}")
|
493
|
+
|
494
|
+
response = litellm.embedding(
|
495
|
+
model="text-embedding-3-small",
|
496
|
+
input=text
|
497
|
+
)
|
498
|
+
embedding = response.data[0]["embedding"]
|
499
|
+
logger.info("Successfully got embeddings from LiteLLM")
|
500
|
+
logger.debug(f"Received embedding of length: {len(embedding)}")
|
501
|
+
|
502
|
+
elif OPENAI_AVAILABLE:
|
503
|
+
# Fallback to OpenAI client
|
504
|
+
from openai import OpenAI
|
505
|
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
506
|
+
|
507
|
+
logger.info("Getting embeddings from OpenAI...")
|
508
|
+
logger.debug(f"Embedding input text: {text}")
|
509
|
+
|
510
|
+
response = client.embeddings.create(
|
511
|
+
input=text,
|
512
|
+
model="text-embedding-3-small"
|
513
|
+
)
|
514
|
+
embedding = response.data[0].embedding
|
515
|
+
logger.info("Successfully got embeddings from OpenAI")
|
516
|
+
logger.debug(f"Received embedding of length: {len(embedding)}")
|
517
|
+
else:
|
518
|
+
logger.warning("Neither litellm nor openai available for embeddings")
|
519
|
+
return
|
480
520
|
|
481
521
|
# Sanitize metadata for ChromaDB
|
482
522
|
sanitized_metadata = self._sanitize_metadata(metadata)
|
@@ -527,15 +567,28 @@ class Memory:
|
|
527
567
|
|
528
568
|
elif self.use_rag and hasattr(self, "chroma_col"):
|
529
569
|
try:
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
570
|
+
if LITELLM_AVAILABLE:
|
571
|
+
# Use LiteLLM for consistency with the rest of the codebase
|
572
|
+
import litellm
|
573
|
+
|
574
|
+
response = litellm.embedding(
|
575
|
+
model="text-embedding-3-small",
|
576
|
+
input=query
|
577
|
+
)
|
578
|
+
query_embedding = response.data[0]["embedding"]
|
579
|
+
elif OPENAI_AVAILABLE:
|
580
|
+
# Fallback to OpenAI client
|
581
|
+
from openai import OpenAI
|
582
|
+
client = OpenAI()
|
583
|
+
|
584
|
+
response = client.embeddings.create(
|
585
|
+
input=query,
|
586
|
+
model="text-embedding-3-small"
|
587
|
+
)
|
588
|
+
query_embedding = response.data[0].embedding
|
589
|
+
else:
|
590
|
+
self._log_verbose("Neither litellm nor openai available for embeddings", logging.WARNING)
|
591
|
+
return []
|
539
592
|
|
540
593
|
# Search ChromaDB with embedding
|
541
594
|
resp = self.chroma_col.query(
|
@@ -910,21 +963,44 @@ class Memory:
|
|
910
963
|
"""
|
911
964
|
|
912
965
|
try:
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
966
|
+
if LITELLM_AVAILABLE:
|
967
|
+
# Use LiteLLM for consistency with the rest of the codebase
|
968
|
+
import litellm
|
969
|
+
|
970
|
+
# Convert model name if it's in litellm format
|
971
|
+
model_name = llm or "gpt-4o-mini"
|
972
|
+
|
973
|
+
response = litellm.completion(
|
974
|
+
model=model_name,
|
975
|
+
messages=[{
|
976
|
+
"role": "user",
|
977
|
+
"content": custom_prompt or default_prompt
|
978
|
+
}],
|
979
|
+
response_format={"type": "json_object"},
|
980
|
+
temperature=0.3
|
981
|
+
)
|
982
|
+
elif OPENAI_AVAILABLE:
|
983
|
+
# Fallback to OpenAI client
|
984
|
+
from openai import OpenAI
|
985
|
+
client = OpenAI()
|
986
|
+
|
987
|
+
response = client.chat.completions.create(
|
988
|
+
model=llm or "gpt-4o-mini",
|
989
|
+
messages=[{
|
990
|
+
"role": "user",
|
991
|
+
"content": custom_prompt or default_prompt
|
992
|
+
}],
|
993
|
+
response_format={"type": "json_object"},
|
994
|
+
temperature=0.3
|
995
|
+
)
|
996
|
+
else:
|
997
|
+
logger.error("Neither litellm nor openai available for quality calculation")
|
998
|
+
return {
|
999
|
+
"completeness": 0.0,
|
1000
|
+
"relevance": 0.0,
|
1001
|
+
"clarity": 0.0,
|
1002
|
+
"accuracy": 0.0
|
1003
|
+
}
|
928
1004
|
|
929
1005
|
metrics = json.loads(response.choices[0].message.content)
|
930
1006
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
praisonaiagents/__init__.py,sha256=
|
1
|
+
praisonaiagents/__init__.py,sha256=0CZDONk4HFIEpij6WwAC2dqwBZ3cdjp0G_CwS98yYk8,1513
|
2
2
|
praisonaiagents/approval.py,sha256=UJ4OhfihpFGR5CAaMphqpSvqdZCHi5w2MGw1MByZ1FQ,9813
|
3
3
|
praisonaiagents/main.py,sha256=_-XE7_Y7ChvtLQMivfNFrrnAhv4wSSDhH9WJMWlkS0w,16315
|
4
4
|
praisonaiagents/session.py,sha256=CI-ffCiOfmgB-1zFFik9daKCB5Sm41Q9ZOaq1-oSLW8,9250
|
@@ -20,7 +20,7 @@ praisonaiagents/mcp/__init__.py,sha256=ibbqe3_7XB7VrIcUcetkZiUZS1fTVvyMy_AqCSFG8
|
|
20
20
|
praisonaiagents/mcp/mcp.py,sha256=_gfp8hrSVT9aPqEDDfU8MiCdg0-3dVQpEQUE6AbrJlo,17243
|
21
21
|
praisonaiagents/mcp/mcp_sse.py,sha256=DLh3F_aoVRM1X-7hgIOWOw4FQ1nGmn9YNbQTesykzn4,6792
|
22
22
|
praisonaiagents/memory/__init__.py,sha256=aEFdhgtTqDdMhc_JCWM-f4XI9cZIj7Wz5g_MUa-0amg,397
|
23
|
-
praisonaiagents/memory/memory.py,sha256=
|
23
|
+
praisonaiagents/memory/memory.py,sha256=W0WwHAXag_vmGXjLBGntXmGqEkZ_AFNrUK2WwR0NEXs,42045
|
24
24
|
praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
|
25
25
|
praisonaiagents/process/process.py,sha256=gxhMXG3s4CzaREyuwE5zxCMx2Wp_b_Wd53tDfkj8Qk8,66567
|
26
26
|
praisonaiagents/task/__init__.py,sha256=VL5hXVmyGjINb34AalxpBMl-YW9m5EDcRkMTKkSSl7c,80
|
@@ -48,7 +48,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
|
|
48
48
|
praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
|
49
49
|
praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
|
50
50
|
praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
|
51
|
-
praisonaiagents-0.0.
|
52
|
-
praisonaiagents-0.0.
|
53
|
-
praisonaiagents-0.0.
|
54
|
-
praisonaiagents-0.0.
|
51
|
+
praisonaiagents-0.0.102.dist-info/METADATA,sha256=XHOa7_oIgLEwegZxOJCVEvDg8Yi6BEpJbX9jxtKhZR8,1503
|
52
|
+
praisonaiagents-0.0.102.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
53
|
+
praisonaiagents-0.0.102.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
|
54
|
+
praisonaiagents-0.0.102.dist-info/RECORD,,
|
File without changes
|
File without changes
|