* refactor(llamaindex): merge two packages into single hindsight-llamaindex Merge `llama-index-tools-hindsight` and `llama-index-memory-hindsight` into a single `hindsight-llamaindex` package following our naming convention. - Rename package to `hindsight-llamaindex` (Python module: `hindsight_llamaindex`) - Move HindsightToolSpec and HindsightMemory into the same package - Delete `llamaindex-memory/` directory - Add CI test job for llamaindex integration - Update docs, blog post, and integrations.json * fix(blog): update llamaindex blog post for merged package - Move date to 2026-03-30 - Add HindsightMemory (automatic BaseMemory) pattern - Fix "bank must exist first" pitfall — mission auto-creates - Align all code examples with docs page - Update architecture diagram to show both patterns * fix(docs): add llamaindex/openai icons, rename Codex - Add llamaindex.png and openai.png icons - Rename "OpenAI Codex CLI" to "Codex" in integrations.json and docs - Use openai.png icon for Codex integration
59 lines
2 KiB
Python
59 lines
2 KiB
Python
"""Manual integration test for Hindsight LlamaIndex tools.
|
|
|
|
Requires a running Hindsight server at http://localhost:8888.
|
|
Run with: uv run pytest tests/test_manual.py -v -s --no-header
|
|
"""
|
|
|
|
import uuid
|
|
|
|
import pytest
|
|
from hindsight_client import Hindsight
|
|
from hindsight_llamaindex import HindsightToolSpec, create_hindsight_tools
|
|
|
|
HINDSIGHT_URL = "http://localhost:8888"
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
return Hindsight(base_url=HINDSIGHT_URL, timeout=30.0)
|
|
|
|
|
|
@pytest.fixture
|
|
def bank_id(client):
|
|
bid = f"test-llamaindex-{uuid.uuid4().hex[:8]}"
|
|
client.create_bank(bank_id=bid, name=bid)
|
|
return bid
|
|
|
|
|
|
@pytest.mark.skip(reason="Requires running Hindsight server")
|
|
class TestManualToolSpec:
|
|
def test_retain_and_recall_round_trip(self, client, bank_id):
|
|
spec = HindsightToolSpec(client=client, bank_id=bank_id)
|
|
|
|
# Retain a memory
|
|
result = spec.retain_memory("The user prefers dark mode in all applications.")
|
|
assert result == "Memory stored successfully."
|
|
|
|
# Recall it
|
|
result = spec.recall_memory("What are the user's UI preferences?")
|
|
assert "dark mode" in result.lower()
|
|
|
|
def test_create_hindsight_tools_factory(self, client, bank_id):
|
|
tools = create_hindsight_tools(client=client, bank_id=bank_id)
|
|
assert len(tools) == 3
|
|
|
|
# Find retain tool by name
|
|
retain_tool = next(t for t in tools if t.metadata.name == "retain_memory")
|
|
result = retain_tool("The user's favorite language is Python.")
|
|
assert "stored" in result.lower()
|
|
|
|
def test_reflect(self, client, bank_id):
|
|
spec = HindsightToolSpec(client=client, bank_id=bank_id)
|
|
|
|
spec.retain_memory("The user is a backend developer.")
|
|
spec.retain_memory("The user uses Python and Go daily.")
|
|
spec.retain_memory("The user prefers vim keybindings.")
|
|
|
|
result = spec.reflect_on_memory("What kind of developer is this user?")
|
|
assert len(result) > 0
|
|
assert result != "No relevant memories found."
|