mirror of
https://github.com/vectorize-io/hindsight.git
synced 2026-09-14 19:31:49 +08:00
6f2799569f
* docs: link every integration changelog from its doc page The release script has written a changelog page per integration since 0.4.20 (src/pages/changelog/integrations/<slug>.md), but nothing reliably linked them: 16 of 61 doc pages carried a "View Changelog" link, and the only index was a hand-written table at the bottom of /changelog listing 6 of the 48 pages, stale since the release that introduced them. coding-agents was one of the 31 pages with a changelog nobody could reach except by guessing the URL. Adds the link to the 30 pages missing one, plus a third invariant in check-integrations.mjs so the next one can't ship unlinked: every changelog page whose integration has a gallery entry must be linked from its doc page. coding-agents.md is generated, so its link goes in the README as an absolute hindsight.vectorize.io URL — the sync script rewrites our own absolute URLs to site-relative, so it resolves on npm, GitHub and the docs site. It sits outside the skill:begin regions, so SKILL.md is unchanged. Claude-Session: https://claude.ai/code/session_01DNWFQn8AUN6SApcswHG3aN * docs(integrations): compact grouped gallery with Docs/Changelog buttons The Integrations Hub listed 60 three-line cards with a repeated "Hindsight Team" byline and an OFFICIAL badge on 52 of them, running 6092px tall — scanning it meant scrolling past what you came for. Cards are now a compact row (icon, name, two-line description) grouped by category, with the featured three using the same row tinted rather than a second card design: 4352px, and the shape of the catalogue is visible at a glance. Each card carries Docs and Changelog buttons. Which integrations have a changelog comes from a new build-time plugin that indexes src/pages/changelog/integrations/*.md and joins integrations.json on the link slug (vercel-ai-sdk -> /sdks/integrations/ai-sdk -> ai-sdk.md), so an integration grows the button on its first release with nothing to update by hand. The card is a <div> now — nested anchors are invalid — so the name and the pills are the links, not the whole card. /changelog's first line points here instead of carrying its own listing. Also drops the 14 CSS classes the old card owned, and shares CATEGORY_LABELS / groupByCategory from src/lib/integrations.ts so the taxonomy has one definition. Claude-Session: https://claude.ai/code/session_01DNWFQn8AUN6SApcswHG3aN
129 lines
3.8 KiB
Markdown
129 lines
3.8 KiB
Markdown
---
|
|
sidebar_position: 34
|
|
title: "Haystack Persistent Memory with Hindsight | Integration"
|
|
description: "Add persistent long-term memory to Haystack agents with Hindsight. Provides retain/recall/reflect Tools plus a HindsightMemoryWrapper with optional auto-recall and auto-retain."
|
|
---
|
|
|
|
# Haystack
|
|
|
|
Persistent long-term memory for [Haystack](https://haystack.deepset.ai/) agents via Hindsight. The `hindsight-haystack` package gives you two complementary patterns:
|
|
|
|
- **`create_hindsight_tools(...)`** — Returns a list of Haystack `Tool`s (`retain_memory`, `recall_memory`, `reflect_on_memory`) the model can call directly inside a turn.
|
|
- **`HindsightMemoryWrapper`** — A Haystack `Toolset` that bundles the same tools and adds optional **auto-recall** (inject relevant memories into the system prompt before each turn) and **auto-retain** (store user + assistant messages after each turn).
|
|
|
|
[View Changelog →](/changelog/integrations/haystack)
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
pip install hindsight-haystack
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
```python
|
|
from hindsight_client import Hindsight
|
|
from hindsight_haystack import create_hindsight_tools
|
|
from haystack.components.agents import Agent
|
|
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
from haystack.dataclasses import ChatMessage
|
|
|
|
client = Hindsight(base_url="http://localhost:8888")
|
|
|
|
tools = create_hindsight_tools(
|
|
client=client,
|
|
bank_id="user-123",
|
|
mission="Track user preferences",
|
|
)
|
|
|
|
agent = Agent(
|
|
chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
|
|
tools=tools,
|
|
system_prompt=(
|
|
"You are a helpful assistant with long-term memory. "
|
|
"Use retain_memory to store important facts. "
|
|
"Use recall_memory to search memory before answering."
|
|
),
|
|
)
|
|
|
|
result = agent.run(messages=[ChatMessage.from_user("Remember that I prefer dark mode")])
|
|
print(result["messages"][-1].text)
|
|
```
|
|
|
|
## Automatic Memory with HindsightMemoryWrapper
|
|
|
|
For automatic recall and retain without relying on the agent to call tools:
|
|
|
|
```python
|
|
from hindsight_haystack import HindsightMemoryWrapper
|
|
|
|
toolset = HindsightMemoryWrapper(
|
|
client=client,
|
|
bank_id="user-123",
|
|
mission="Track user preferences",
|
|
auto_recall=True, # Inject memories into the system prompt before each turn
|
|
auto_retain=True, # Store user + assistant messages after each turn
|
|
)
|
|
|
|
agent = Agent(
|
|
chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
|
|
tools=toolset,
|
|
system_prompt="You are a helpful assistant with long-term memory.",
|
|
)
|
|
|
|
# Use toolset.run() for automatic memory behavior
|
|
result = toolset.run(agent, messages=[ChatMessage.from_user("I prefer dark mode")])
|
|
```
|
|
|
|
## Selective Tools
|
|
|
|
```python
|
|
# Only retain + recall (no reflect)
|
|
tools = create_hindsight_tools(
|
|
client=client,
|
|
bank_id="user-123",
|
|
include_reflect=False,
|
|
)
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Call `configure()` once to set connection defaults so you can omit `client=`/`hindsight_api_url=` on every call:
|
|
|
|
```python
|
|
from hindsight_haystack import configure
|
|
|
|
configure(
|
|
hindsight_api_url="http://localhost:8888",
|
|
api_key="your-api-key",
|
|
budget="mid",
|
|
tags=["source:haystack"],
|
|
context="my-app",
|
|
mission="Track user preferences",
|
|
)
|
|
|
|
tools = create_hindsight_tools(bank_id="user-123")
|
|
```
|
|
|
|
The API URL defaults to Hindsight Cloud (`https://api.hindsight.vectorize.io`), and the API key falls back to the `HINDSIGHT_API_KEY` environment variable.
|
|
|
|
## Requirements
|
|
|
|
- Python 3.10+
|
|
- `haystack-ai >= 2.12.0`
|
|
- `hindsight-client >= 0.4.0`
|
|
|
|
## Prerequisites
|
|
|
|
A running Hindsight instance:
|
|
|
|
**Hindsight Cloud (recommended):** [Sign up](https://ui.hindsight.vectorize.io/signup) — no self-hosting required.
|
|
|
|
**Self-hosted:**
|
|
|
|
```bash
|
|
pip install hindsight-all
|
|
export HINDSIGHT_API_LLM_API_KEY=your-api-key
|
|
hindsight-api # starts on http://localhost:8888
|
|
```
|