Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

AxContextCacheRegistry

type AxContextCacheRegistry = object;

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/ai/types.ts#L488

External registry for persisting context cache metadata. Useful for serverless/short-lived processes where in-memory storage is lost.

Example

// Redis-backed registry
const registry: AxContextCacheRegistry = {
  get: async (key) => {
    const data = await redis.get(`cache:${key}`);
    return data ? JSON.parse(data) : undefined;
  },
  set: async (key, entry) => {
    await redis.set(`cache:${key}`, JSON.stringify(entry), 'EX', 3600);
  },
};

Properties

get()

get: (key: string) => 
  | Promise<
  | AxContextCacheRegistryEntry
  | undefined>
  | AxContextCacheRegistryEntry
  | undefined;

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/ai/types.ts#L490

Look up a cache entry by key

Parameters

ParameterType
keystring

Returns

| Promise< | AxContextCacheRegistryEntry | undefined> | AxContextCacheRegistryEntry | undefined


set()

set: (key: string, entry: Readonly<AxContextCacheRegistryEntry>) => Promise<void> | void;

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/ai/types.ts#L497

Store a cache entry

Parameters

ParameterType
keystring
entryReadonly<AxContextCacheRegistryEntry>

Returns

Promise<void> | void