trace-memory 1.0.3__tar.gz → 1.0.5__tar.gz
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.
- {trace_memory-1.0.3/trace_memory.egg-info → trace_memory-1.0.5}/PKG-INFO +20 -7
- {trace_memory-1.0.3 → trace_memory-1.0.5}/README.md +19 -6
- {trace_memory-1.0.3 → trace_memory-1.0.5}/pyproject.toml +1 -1
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory/ctree.py +29 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory/prompt_synthesizer.py +2 -2
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory/vector_db.py +1 -1
- {trace_memory-1.0.3 → trace_memory-1.0.5/trace_memory.egg-info}/PKG-INFO +20 -7
- {trace_memory-1.0.3 → trace_memory-1.0.5}/LICENSE +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/NOTICE +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/setup.cfg +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory/__init__.py +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory/_llm_utils.py +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory.egg-info/SOURCES.txt +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory.egg-info/dependency_links.txt +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory.egg-info/requires.txt +0 -0
- {trace_memory-1.0.3 → trace_memory-1.0.5}/trace_memory.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trace-memory
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: TRACE — Temporal Retrieval And Context Engine: self-healing hierarchical memory for LLM agents.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/husain34/TRACE
|
|
@@ -495,6 +495,9 @@ vdb = VectorDatabase("path/to/session.db") # creates the DB if it doesn't exist
|
|
|
495
495
|
|
|
496
496
|
Store an embedded past conversation message for cross-thread recall.
|
|
497
497
|
|
|
498
|
+
> [!NOTE]
|
|
499
|
+
> As of TRACE 1.0.4, `CTree.add()` calls this **automatically** behind the scenes. You only need to call this manually if you are managing the Vector DB independently of a CTree.
|
|
500
|
+
|
|
498
501
|
```python
|
|
499
502
|
from trace_memory import ConversationVector
|
|
500
503
|
import time, uuid
|
|
@@ -638,15 +641,25 @@ tree = CTree(api_key="sk-...", model="gpt-4o-mini")
|
|
|
638
641
|
|
|
639
642
|
### 7.3 With NVIDIA NIM / any OpenAI-compatible endpoint
|
|
640
643
|
|
|
641
|
-
|
|
642
|
-
import os
|
|
643
|
-
os.environ["OPENAI_BASE_URL"] = "https://integrate.api.nvidia.com/v1"
|
|
644
|
-
os.environ["OPENAI_API_KEY"] = "nvapi-..."
|
|
644
|
+
Point the `base_url` to your endpoint.
|
|
645
645
|
|
|
646
|
-
|
|
647
|
-
tree = CTree(
|
|
646
|
+
```python
|
|
647
|
+
tree = CTree(
|
|
648
|
+
api_key="your-nvidia-api-key",
|
|
649
|
+
base_url="https://integrate.api.nvidia.com/v1",
|
|
650
|
+
model="meta/llama-3.1-8b-instruct"
|
|
651
|
+
)
|
|
648
652
|
```
|
|
649
653
|
|
|
654
|
+
### 7.4 Best Practices for LLM Selection
|
|
655
|
+
|
|
656
|
+
**Do not use "Reasoning" models (DeepSeek R1, Claude 3.7 Sonnet thinking mode, o1) for the internal `CTree` engine.**
|
|
657
|
+
|
|
658
|
+
When `CTree` runs in the background, it performs simple, deterministic classification tasks (e.g., naming a topic in 3 words, or extracting a JSON boolean). Reasoning models are built for complex logic and will waste massive amounts of compute "thinking" about simple tasks. Worse, reasoning models often exceed TRACE's strict internal token limits (`max_tokens=50` or `200`) designed to keep background operations fast, causing the LLM to get cut off mid-thought and breaking the internal JSON parsers.
|
|
659
|
+
|
|
660
|
+
* **For the `CTree` internal model:** Always use a fast, standard model (e.g., `gpt-4o-mini`, `meta-llama-3.1-8b-instruct`).
|
|
661
|
+
* **For your actual chat application:** You can (and should!) use whatever massive reasoning model you prefer to generate the final response to the user. TRACE is completely decoupled from your front-end chat completion.
|
|
662
|
+
|
|
650
663
|
---
|
|
651
664
|
|
|
652
665
|
## 8. Edge-Case Stress Tests & Validation
|
|
@@ -466,6 +466,9 @@ vdb = VectorDatabase("path/to/session.db") # creates the DB if it doesn't exist
|
|
|
466
466
|
|
|
467
467
|
Store an embedded past conversation message for cross-thread recall.
|
|
468
468
|
|
|
469
|
+
> [!NOTE]
|
|
470
|
+
> As of TRACE 1.0.4, `CTree.add()` calls this **automatically** behind the scenes. You only need to call this manually if you are managing the Vector DB independently of a CTree.
|
|
471
|
+
|
|
469
472
|
```python
|
|
470
473
|
from trace_memory import ConversationVector
|
|
471
474
|
import time, uuid
|
|
@@ -609,15 +612,25 @@ tree = CTree(api_key="sk-...", model="gpt-4o-mini")
|
|
|
609
612
|
|
|
610
613
|
### 7.3 With NVIDIA NIM / any OpenAI-compatible endpoint
|
|
611
614
|
|
|
612
|
-
|
|
613
|
-
import os
|
|
614
|
-
os.environ["OPENAI_BASE_URL"] = "https://integrate.api.nvidia.com/v1"
|
|
615
|
-
os.environ["OPENAI_API_KEY"] = "nvapi-..."
|
|
615
|
+
Point the `base_url` to your endpoint.
|
|
616
616
|
|
|
617
|
-
|
|
618
|
-
tree = CTree(
|
|
617
|
+
```python
|
|
618
|
+
tree = CTree(
|
|
619
|
+
api_key="your-nvidia-api-key",
|
|
620
|
+
base_url="https://integrate.api.nvidia.com/v1",
|
|
621
|
+
model="meta/llama-3.1-8b-instruct"
|
|
622
|
+
)
|
|
619
623
|
```
|
|
620
624
|
|
|
625
|
+
### 7.4 Best Practices for LLM Selection
|
|
626
|
+
|
|
627
|
+
**Do not use "Reasoning" models (DeepSeek R1, Claude 3.7 Sonnet thinking mode, o1) for the internal `CTree` engine.**
|
|
628
|
+
|
|
629
|
+
When `CTree` runs in the background, it performs simple, deterministic classification tasks (e.g., naming a topic in 3 words, or extracting a JSON boolean). Reasoning models are built for complex logic and will waste massive amounts of compute "thinking" about simple tasks. Worse, reasoning models often exceed TRACE's strict internal token limits (`max_tokens=50` or `200`) designed to keep background operations fast, causing the LLM to get cut off mid-thought and breaking the internal JSON parsers.
|
|
630
|
+
|
|
631
|
+
* **For the `CTree` internal model:** Always use a fast, standard model (e.g., `gpt-4o-mini`, `meta-llama-3.1-8b-instruct`).
|
|
632
|
+
* **For your actual chat application:** You can (and should!) use whatever massive reasoning model you prefer to generate the final response to the user. TRACE is completely decoupled from your front-end chat completion.
|
|
633
|
+
|
|
621
634
|
---
|
|
622
635
|
|
|
623
636
|
## 8. Edge-Case Stress Tests & Validation
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "trace-memory"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.5"
|
|
8
8
|
description = "TRACE — Temporal Retrieval And Context Engine: self-healing hierarchical memory for LLM agents."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "Apache-2.0" }
|
|
@@ -427,6 +427,35 @@ class CTree:
|
|
|
427
427
|
else:
|
|
428
428
|
self._add_message(msg_dict)
|
|
429
429
|
|
|
430
|
+
if self.vdb:
|
|
431
|
+
from .vector_db import ConversationVector
|
|
432
|
+
import uuid
|
|
433
|
+
|
|
434
|
+
ancestors = self.get_ancestors(self.current_node, include_self=True, exclude_root=False)
|
|
435
|
+
thread_path = " → ".join([n.topic_name for n in ancestors]) if ancestors else "ROOT"
|
|
436
|
+
|
|
437
|
+
start_idx = msg_dict["index"]
|
|
438
|
+
for i, msg in enumerate(messages):
|
|
439
|
+
role = msg.get("role", "")
|
|
440
|
+
text = msg.get("content", "")
|
|
441
|
+
if not text or not isinstance(text, str):
|
|
442
|
+
continue
|
|
443
|
+
|
|
444
|
+
try:
|
|
445
|
+
embed_vec = self.embed_fn(text)
|
|
446
|
+
c_vec = ConversationVector(
|
|
447
|
+
message_id=str(uuid.uuid4()),
|
|
448
|
+
message_index=start_idx + i,
|
|
449
|
+
role=role,
|
|
450
|
+
text=text,
|
|
451
|
+
embedding=embed_vec,
|
|
452
|
+
timestamp=time.time(),
|
|
453
|
+
thread_path=thread_path
|
|
454
|
+
)
|
|
455
|
+
self.vdb.add_conversation_message(c_vec)
|
|
456
|
+
except Exception:
|
|
457
|
+
pass
|
|
458
|
+
|
|
430
459
|
if self.auto_save_path:
|
|
431
460
|
self.save(self.auto_save_path, save_conversation=True)
|
|
432
461
|
|
|
@@ -159,8 +159,8 @@ class PromptSynthesizer:
|
|
|
159
159
|
query_vector: list,
|
|
160
160
|
active_node,
|
|
161
161
|
recent_messages: list,
|
|
162
|
-
top_k_history: int =
|
|
163
|
-
min_history_similarity: float = 0.
|
|
162
|
+
top_k_history: int = 5,
|
|
163
|
+
min_history_similarity: float = 0.25,
|
|
164
164
|
) -> str:
|
|
165
165
|
"""
|
|
166
166
|
Assemble the full enriched system prompt for the next LLM turn.
|
|
@@ -94,7 +94,7 @@ class VectorDatabase:
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
def search_conversation(self, query_vector, top_k=
|
|
97
|
+
def search_conversation(self, query_vector, top_k=5, min_similarity=0.25):
|
|
98
98
|
if not query_vector:
|
|
99
99
|
return []
|
|
100
100
|
conn = sqlite3.connect(self.db_path)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trace-memory
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5
|
|
4
4
|
Summary: TRACE — Temporal Retrieval And Context Engine: self-healing hierarchical memory for LLM agents.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/husain34/TRACE
|
|
@@ -495,6 +495,9 @@ vdb = VectorDatabase("path/to/session.db") # creates the DB if it doesn't exist
|
|
|
495
495
|
|
|
496
496
|
Store an embedded past conversation message for cross-thread recall.
|
|
497
497
|
|
|
498
|
+
> [!NOTE]
|
|
499
|
+
> As of TRACE 1.0.4, `CTree.add()` calls this **automatically** behind the scenes. You only need to call this manually if you are managing the Vector DB independently of a CTree.
|
|
500
|
+
|
|
498
501
|
```python
|
|
499
502
|
from trace_memory import ConversationVector
|
|
500
503
|
import time, uuid
|
|
@@ -638,15 +641,25 @@ tree = CTree(api_key="sk-...", model="gpt-4o-mini")
|
|
|
638
641
|
|
|
639
642
|
### 7.3 With NVIDIA NIM / any OpenAI-compatible endpoint
|
|
640
643
|
|
|
641
|
-
|
|
642
|
-
import os
|
|
643
|
-
os.environ["OPENAI_BASE_URL"] = "https://integrate.api.nvidia.com/v1"
|
|
644
|
-
os.environ["OPENAI_API_KEY"] = "nvapi-..."
|
|
644
|
+
Point the `base_url` to your endpoint.
|
|
645
645
|
|
|
646
|
-
|
|
647
|
-
tree = CTree(
|
|
646
|
+
```python
|
|
647
|
+
tree = CTree(
|
|
648
|
+
api_key="your-nvidia-api-key",
|
|
649
|
+
base_url="https://integrate.api.nvidia.com/v1",
|
|
650
|
+
model="meta/llama-3.1-8b-instruct"
|
|
651
|
+
)
|
|
648
652
|
```
|
|
649
653
|
|
|
654
|
+
### 7.4 Best Practices for LLM Selection
|
|
655
|
+
|
|
656
|
+
**Do not use "Reasoning" models (DeepSeek R1, Claude 3.7 Sonnet thinking mode, o1) for the internal `CTree` engine.**
|
|
657
|
+
|
|
658
|
+
When `CTree` runs in the background, it performs simple, deterministic classification tasks (e.g., naming a topic in 3 words, or extracting a JSON boolean). Reasoning models are built for complex logic and will waste massive amounts of compute "thinking" about simple tasks. Worse, reasoning models often exceed TRACE's strict internal token limits (`max_tokens=50` or `200`) designed to keep background operations fast, causing the LLM to get cut off mid-thought and breaking the internal JSON parsers.
|
|
659
|
+
|
|
660
|
+
* **For the `CTree` internal model:** Always use a fast, standard model (e.g., `gpt-4o-mini`, `meta-llama-3.1-8b-instruct`).
|
|
661
|
+
* **For your actual chat application:** You can (and should!) use whatever massive reasoning model you prefer to generate the final response to the user. TRACE is completely decoupled from your front-end chat completion.
|
|
662
|
+
|
|
650
663
|
---
|
|
651
664
|
|
|
652
665
|
## 8. Edge-Case Stress Tests & Validation
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|