new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

hindsight/setup

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Hindsight provider package name and source

The Hindsight provider for the AI SDK is distributed as the npm package `@vectorize-io/hindsight-ai-sdk`. The client library is `@vectorize-io/hindsight-client`. Hindsight is a persistent memory service for AI agents available at https://hindsight.vectorize.io.

Hindsight self-hosted setup with Docker

Hindsight can be run locally using Docker. The command is: `docker run --rm -it -p 8888:8888 -p 9999:9999 -e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY -v $HOME/.hindsight-docker:/home/hindsight/.pg0 ghcr.io/vectorize-io/hindsight:latest`. The API will be available at `http://localhost:8888` and the UI at `http://localhost:9999`. The `OPENAI_API_KEY` environment variable must be exported before running the command.

Hindsight cloud setup

To use Hindsight as a cloud service, sign up and get your API URL from the Hindsight dashboard at https://ui.hindsight.vectorize.io/signup.

Hindsight HindsightClient initialization

Initialize a HindsightClient by passing a baseUrl configuration: `new HindsightClient({ baseUrl: process.env.HINDSIGHT_API_URL })`.

Hindsight createHindsightTools initialization

Initialize Hindsight tools by calling `createHindsightTools({ client, bankId: 'user-id' })`. The `client` parameter is a HindsightClient instance. The `bankId` parameter identifies the memory store and typically contains a user ID for multi-user memory isolation.

Hindsight multi-user memory isolation

To isolate memory per user in multi-user applications, create `createHindsightTools` inside request handlers so each request uses the correct `bankId` for the authenticated user. The HindsightClient instance should be created once at module level and reused, while `createHindsightTools` is called per-request with the current user's ID.

Hindsight generateText example

Example using Hindsight tools with generateText: ```ts import { HindsightClient } from '@vectorize-io/hindsight-client'; import { createHindsightTools } from '@vectorize-io/hindsight-ai-sdk'; import { generateText, isStepCount } from 'ai'; import { openai } from '@ai-sdk/openai'; const client = new HindsightClient({ baseUrl: process.env.HINDSIGHT_API_URL }); const tools = createHindsightTools({ client, bankId: 'user-123' }); const { text } = await generateText({ model: openai('gpt-4o'), tools, stopWhen: isStepCount(5), system: 'You are a helpful assistant with long-term memory.', prompt: 'Remember that I prefer dark mode and large fonts.', }); ```

Hindsight ToolLoopAgent example

Example using Hindsight tools with ToolLoopAgent: ```ts import { ToolLoopAgent } from 'ai'; import { openai } from '@ai-sdk/openai'; import { HindsightClient } from '@vectorize-io/hindsight-client'; import { createHindsightTools } from '@vectorize-io/hindsight-ai-sdk'; const client = new HindsightClient({ baseUrl: process.env.HINDSIGHT_API_URL }); const agent = new ToolLoopAgent({ model: openai('gpt-4o'), tools: createHindsightTools({ client, bankId: 'user-123' }), instructions: 'You are a helpful assistant with long-term memory.', }); const result = await agent.generate({ prompt: 'Remember that my favorite editor is Neovim', }); ```

Hindsight streamText with multi-user example

Example using Hindsight tools with streamText in a multi-user context: ```ts // app/api/chat/route.ts import { createUIMessageStreamResponse, streamText, isStepCount, convertToModelMessages, toUIMessageStream, } from 'ai'; import { openai } from '@ai-sdk/openai'; import { HindsightClient } from '@vectorize-io/hindsight-client'; import { createHindsightTools } from '@vectorize-io/hindsight-ai-sdk'; const hindsightClient = new HindsightClient({ baseUrl: process.env.HINDSIGHT_API_URL, }); export async function POST(req: Request) { const { messages, userId } = await req.json(); const tools = createHindsightTools({ client: hindsightClient, bankId: userId, }); const result = streamText({ model: openai('gpt-4o'), tools, stopWhen: isStepCount(5), system: 'You are a helpful assistant with long-term memory.', messages: await convertToModelMessages(messages), }); return createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }), }); } ```

Give your agent this brain