PageSourceSearch

https://smritea.ai/assets/ExamplesPage-BYgnBvgI.js

js smritea.ai collected 2026-10-05 15:06:57 UTC 32,238 bytes, 337 lines download raw bytes

1import{j as e,r as f,B as y,L as g,d as x}from"./index-OkXy-d5Y.js";import{S as j}from"./SeoHead-B8UDfQqR.js";import{C as o,a as b}from"./CTASection-CU6payEt.js";import{C as m,S as l,E as v}from"./CodeWindow-BIXuFLiG.js";import{S as p}from"./StatProofCard-dn8rp0OX.js";import"./CopyButton-Bg3eIyIl.js";function S(){return e.jsxs(o,{className:"py-[70px] pb-10 text-center",children:[e.jsx("h1",{className:"display text-[length:var(--h1-size)] text-foreground mb-4",children:"Build anything with the Smritea API"}),e.jsx("p",{className:"text-[17px] text-muted-foreground max-w-[54ch] mx-auto",children:"Everything you need to add persistent memory to your product and personal AI workflows."})]})}const w={create:"Store a fact about a user — Smritea extracts the entities automatically.",search:"Ask a plain-language question; get the user's relevant memories back, ranked.",graph:"Follow links between entities — deep_search walks the graph to connect facts.",filters:"Restrict a search to memories whose metadata matches your filter."},u={create:"Memory Creation",search:"Memory Search",graph:"Knowledge Graph",filters:"Metadata Filters"},_={create:{py:`from smritea import SmriteaClient
2from smritea.types import MemoryScope
3client = SmriteaClient(api_key="YOUR_API_KEY", app_id="YOUR_APP_ID")
4
5# create memory — facts & entities extracted automatically
6client.add(
7    "Priya leads the Atlas migration",
8    scope=MemoryScope(actor_id="priya", actor_type="user"),
9)`,ts:`import { SmriteaClient } from "smritea-sdk";
10const client = new SmriteaClient({ apiKey, appId });
11
12// create memory — facts & entities extracted automatically
13await client.add("Priya leads the Atlas migration", {
14  scope: { actorId: "priya", actorType: "user" },
15});`,go:`import (
16    "context"
17    smritea "github.com/SmrutAI/smritea-sdk/go"
18)
19
20client := smritea.NewClient(smritea.ClientConfig{
21    APIKey: "YOUR_API_KEY", AppID: "YOUR_APP_ID",
22})
23ctx := context.Background()
24
25// create memory — facts & entities extracted automatically
26client.Add(ctx, "Priya leads the Atlas migration",
27    smritea.NewAddOptions().WithScope(
28        smritea.NewMemoryScope().WithActorID("priya").WithActorType("user"),
29    ),
30)`,bash:`curl -X POST https://api-us.smritea.ai/api/v1/sdk/memories \\
31  -H "X-API-Key: $SMRITEA_API_KEY" \\
32  -H "Content-Type: application/json" \\
33  -d '{
34    "app_id": "YOUR_APP_ID",
35    "content": "Priya leads the Atlas migration",
36    "scope": { "actor_id": "priya", "actor_type": "user" }
37  }'`},search:{py:`# search memory in natural language
38hits = client.search(
39    "What is Priya working on?",
40    scope=MemoryScope(actor_id="priya", actor_type="user"),
41)
42for r in hits:
43    print(r.score, r.memory.content)`,ts:`// search memory in natural language
44const hits = await client.search("What is Priya working on?", {
45  scope: { actorId: "priya", actorType: "user" },
46});
47hits.forEach(r => console.log(r.score, r.memory?.content));`,go:`// search memory in natural language
48results, err := client.Search(ctx, "What is Priya working on?",
49    smritea.NewSearchOptions().WithScope(
50        smritea.NewMemoryScope().WithActorID("priya").WithActorType("user"),
51    ),
52)
53// results: []*smritea.SearchResult, ranked by relevance`,bash:`curl -X POST https://api-us.smritea.ai/api/v1/sdk/memories/search \\
54  -H "X-API-Key: $SMRITEA_API_KEY" \\
55  -H "Content-Type: application/json" \\
56  -d '{
57    "app_id": "YOUR_APP_ID",
58    "query": "What is Priya working on?",
59    "scope": { "actor_id": "priya", "actor_type": "user" }
60  }'`},graph:{py:`# graph-aware search traverses linked entities
61deep = client.search(
62    "Tell me about the Atlas team",
63    scope=MemoryScope(actor_id="priya", actor_type="user"),
64    method="deep_search", graph_depth=2,
65)`,ts:`// graph-aware search traverses linked entities
66const deep = await client.search("Tell me about the Atlas team", {
67  scope: { actorId: "priya", actorType: "user" },
68  method: "deep_search", graphDepth: 2,
69});`,go:`// graph-aware search traverses linked entities
70deep, err := client.Search(ctx, "Tell me about the Atlas team",
71    smritea.NewSearchOptions().
72        WithScope(smritea.NewMemoryScope().WithActorID("priya").WithActorType("user")).
73        WithMethod("deep_search").
74        WithGraphDepth(2),
75)`,bash:`curl -X POST https://api-us.smritea.ai/api/v1/sdk/memories/search \\
76  -H "X-API-Key: $SMRITEA_API_KEY" \\
77  -H "Content-Type: application/json" \\
78  -d '{
79    "app_id": "YOUR_APP_ID",
80    "query": "Tell me about the Atlas team",
81    "method": "deep_search",
82    "graph_depth": 2,
83    "scope": { "actor_id": "priya", "actor_type": "user" }
84  }'`},filters:{py:`# filter results by metadata (Mongo-style operators)
85hits = client.search(
86    "premium features",
87    scope=MemoryScope(actor_id="org-1", actor_type="system"),
88    metadata_filter={"tier": {"$eq": "premium"}},
89)`,ts:`// filter results by metadata (Mongo-style operators)
90const hits = await client.search("premium features", {
91  scope: { actorId: "org-1", actorType: "system" },
92  metadataFilter: { tier: { $eq: "premium" } },
93});`,go:`// filter results by metadata (Mongo-style operators)
94results, err := client.Search(ctx, "premium features",
95    smritea.NewSearchOptions().
96        WithScope(smritea.NewMemoryScope().WithActorID("org-1").WithActorType("system")).
97        WithMetadataFilter(map[string]any{"tier": map[string]any{"$eq": "premium"}}),
98)`,bash:`curl -X POST https://api-us.smritea.ai/api/v1/sdk/memories/search \\
99  -H "X-API-Key: $SMRITEA_API_KEY" \\
100  -H "Content-Type: application/json" \\
101  -d '{
102    "app_id": "YOUR_APP_ID",
103    "query": "premium features",
104    "metadata_filter": { "tier": { "$eq": "premium" } },
105    "scope": { "actor_id": "org-1", "actor_type": "system" }
106  }'`}},k=[{key:"create",icon:e.jsxs("svg",{viewBox:"0 0 24 24",width:19,height:19,fill:"none",stroke:"currentColor",strokeWidth:1.7,children:[e.jsx("path",{d:"M12 3l7 4v6c0 4-3 6-7 8-4-2-7-4-7-8V7z"}),e.jsx("path",{d:"M9 12l2 2 4-4"})]}),desc:"Store any text — facts & entities are extracted automatically."},{key:"search",icon:e.jsxs("svg",{viewBox:"0 0 24 24",width:19,height:19,fill:"none",stroke:"currentColor",strokeWidth:1.7,children:[e.jsx("circle",{cx:11,cy:11,r:7}),e.jsx("path",{d:"M21 21l-4-4"})]}),desc:"Vector, graph, and LLM search across everything you've stored."},{key:"graph",icon:e.jsxs("svg",{viewBox:"0 0 24 24",width:19,height:19,fill:"none",stroke:"currentColor",strokeWidth:1.7,children:[e.jsx("circle",{cx:6,cy:6,r:2.3}),e.jsx("circle",{cx:18,cy:9,r:2.3}),e.jsx("circle",{cx:9,cy:18,r:2.3}),e.jsx("path",{d:"M8 7l8 1M8 8v8"})]}),desc:"Entities resolved & linked — traverse with deep_search."},{key:"filters",icon:e.jsx("svg",{viewBox:"0 0 24 24",width:19,height:19,fill:"none",stroke:"currentColor",strokeWidth:1.7,children:e.jsx("path",{d:"M3 5h18M6 12h12M10 19h4"})}),desc:"Mongo-style operators on any field at search time."}];function N(){const[r,a]=f.useState("create"),s=_[r];return e.jsx("div",{children:e.jsxs("div",{className:"grid grid-cols-1 items-start gap-7 lg:grid-cols-[clamp(440px,45vw,560px)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"archframe-card p-[34px] min-w-0",children:[e.jsxs("h3",{className:"mb-[6px] text-[26px] font-semibold leading-[1.25] tracking-[-0.02em] text-[color:var(--ink)]",children:["Add ",e.jsx("span",{className:"text-[color:var(--brand-highlight)]",children:u[r]}),e.jsx("br",{}),"to your app in minutes"]}),e.jsx("p",{className:"mb-5 min-h-[42px] text-sm leading-[1.5] text-[color:var(--muted-foreground)]",children:w[r]}),e.jsx(m,{snippets:{py:s.py,ts:s.ts,go:s.go,bash:s.bash},defaultLang:"py",tabLabels:{py:"py",ts:"ts",go:"go",bash:"cURL"},tabBadges:{bash:"c"},contentClassName:"h-[320px] overflow-auto"}
106),e.jsx(y,{asChild:!0,className:"mt-[22px] w-full py-[15px] text-[15px]",children:e.jsx(g,{to:"/auth/login",children:"Get your API key & get started"})})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"grid grid-cols-2 gap-[14px]",children:k.map(t=>e.jsxs("button",{type:"button",onClick:()=>a(t.key),className:`archframe-card relative min-h-[150px] cursor-pointer overflow-hidden p-[22px] text-left ${r===t.key?"shadow-[var(--glow)]":""}`,children:[r===t.key&&e.jsx("span",{className:"pointer-events-none absolute right-[-30px] top-[-30px] h-[120px] w-[120px] rounded-full bg-[radial-gradient(circle,var(--glow-blob),transparent_68%)] blur-[6px]","aria-hidden":"true"}),e.jsxs("span",{className:"relative z-10 block",children:[e.jsx("span",{className:"mb-4 flex h-[38px] w-[38px] items-center justify-center rounded-[11px] border border-[color:var(--line)] bg-[color:var(--wash)] text-[color:var(--ink)]",children:t.icon}),e.jsx("span",{className:"mb-1.5 block text-[16.5px] font-semibold text-[color:var(--ink)]",children:u[t.key]}),e.jsx("span",{className:"m-0 block text-[13.5px] leading-[1.5] text-[color:var(--muted-foreground)]",children:t.desc})]})]},t.key))}),e.jsxs("div",{className:"mt-[14px] grid grid-cols-1 gap-[14px] sm:grid-cols-[0.82fr_1.36fr_0.82fr]",children:[e.jsxs("div",{className:"archframe-card px-[18px] py-[18px]",children:[e.jsx("h5",{className:"mb-[5px] text-[14.5px] font-semibold text-[color:var(--ink)]",children:"REST API"}),e.jsx("p",{className:"m-0 text-[12.5px] text-[color:var(--muted-foreground)]",children:"Clean, documented endpoints."})]}),e.jsxs("div",{className:"archframe-card px-[18px] py-[18px]",children:[e.jsx("h5",{className:"mb-[5px] text-[14.5px] font-semibold text-[color:var(--ink)]",children:"Python · TS · Go SDK"}),e.jsxs("p",{className:"m-0 text-[12.5px] leading-[1.8] text-[color:var(--muted-foreground)]",children:[e.jsx("span",{className:"font-mono text-[11.5px] whitespace-nowrap text-[color:var(--ink)]",children:"pip install smritea-sdk"}),e.jsx("br",{}),e.jsx("span",{className:"font-mono text-[11.5px] whitespace-nowrap text-[color:var(--ink)]",children:"npm install smritea-sdk"})]})]}),e.jsxs("div",{className:"archframe-card px-[18px] py-[18px]",children:[e.jsx("h5",{className:"mb-[5px] text-[14.5px] font-semibold text-[color:var(--ink)]",children:"Playground"}),e.jsx("p",{className:"m-0 text-[12.5px] text-[color:var(--muted-foreground)]",children:"Test in the dashboard, no setup."})]})]})]})]})})}function A(){return e.jsx(o,{className:"pb-[54px]",children:e.jsx(N,{})})}function d({number:r,title:a,body:s,className:t}){return e.jsxs("div",{className:x("archframe-card p-5",t),children:[e.jsx("div",{className:"mb-3.5 grid h-10 w-10 place-items-center rounded-full border border-[color:var(--line)] bg-[var(--wash)] font-mono text-sm font-semibold text-[color:var(--ink)]",children:r}),e.jsx("h4",{className:"mb-1.5 text-[15px] font-semibold text-[color:var(--ink)]",children:a}),e.jsx("p",{className:"text-[13px] leading-[1.5] text-[color:var(--muted-foreground)]",children:s})]})}function I(){return e.jsx("section",{className:"section",children:e.jsxs(o,{children:[e.jsx(l,{eyebrow:"How it works",title:"Four steps from zero to memory-powered AI."}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 md:grid-cols-4",children:[e.jsx(d,{number:"01",title:"Create an App & Get API Key",body:"Sign up, create an app in the dashboard, and copy your API key and App ID. Each key is scoped to one app — your users' memories stay isolated."}),e.jsx(d,{number:"02",title:"Install the SDK",body:e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-[11.5px]",children:"pip install smritea-sdk"})," or ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"npm install smritea-sdk"}),". Initialize ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"SmriteaClient"})," with your key and app ID."]})}),e.jsx(d,{number:"03",title:"Store & Search",body:e.jsxs(e.Fragment,{children:["Call ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"add()"})," to store any text — entity extraction & graph indexing happen automatically. Call ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"search()"})," with natural language."]})}),e.jsx(d,{number:"04",title:"Feed Context to Your LLM",body:"Results come back with relevance scores and metadata. Inject them into your prompt's system message. Your LLM now has memory."})]})]})})}function c({tag:r,title:a,body:s,span2:t,className:i}){return e.jsxs("div",{className:x("archframe-card p-[22px]",t&&"md:col-span-2",i),children:[e.jsx("span",{className:"mb-3 inline-block rounded-[7px] border border-(--color-border) bg-muted px-[9px] py-[3px] font-mono text-[11.5px] text-primary",children:r}),e.jsx("h4",{className:"mb-2 text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"text-[13.5px] leading-[1.55] text-muted-foreground",children:s})]})}function C(){return e.jsx("section",{className:"section",children:e.jsxs(o,{children:[e.jsx(l,{eyebrow:"Core concepts",title:"Five ideas that make the rest click.",lead:"A quick mental model before the code — how memories are owned, isolated, and filtered."}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsx(c,{tag:"app_id",title:"Ap
106p ID",body:"Every memory lives under an app. Your API key is tied to one app, so data from different apps never mixes. Set it once on the client — it's attached to every call automatically."}),e.jsx(c,{tag:"actor_id + actor_type",title:"Actor ID & Type",body:e.jsxs(e.Fragment,{children:["Who a memory is about. ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"actor_type"})," is ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"user"}),", ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"agent"}),", or ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"system"}),"; ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"actor_id"})," is that actor's ID in your product. Search returns only the matching actor's memories — so each end-user gets private memory."]})}),e.jsx(c,{tag:"conversation_id",title:"Conversation ID",body:"Optional. Groups memories into one conversation thread, so a multi-turn exchange is stored and recalled together, in order."}),e.jsx(c,{tag:"metadata",title:"Metadata",body:e.jsxs(e.Fragment,{children:["Arbitrary key–value tags, e.g. ",e.jsx("code",{className:"font-mono text-[11.5px]",children:'{"tier": "pro"}'}),". Values must be strings or numbers — booleans and nested objects are rejected. Filter on them at search time with Mongo-style operators (",e.jsx("code",{className:"font-mono text-[11.5px]",children:"$eq"}),", ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"$gte"}),", ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"$in"}),", ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"$and"}),")."]})}),e.jsx(c,{tag:"scope",title:"Memory Scope — how it all ties together",body:e.jsxs(e.Fragment,{children:["Scope is the combination of ",e.jsx("b",{children:"App + Actor"})," (+ optional ",e.jsx("b",{children:"Conversation"}),") that a memory belongs to. Every ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"add()"})," writes into a scope; every ",e.jsx("code",{className:"font-mono text-[11.5px]",children:"search()"})," reads within one. Getting scope right is what keeps results isolated (per user, per app) and relevant."]}),span2:!0})]})]})})}function n({level:r,title:a,description:s,window:t,className:i}){return r===1?e.jsx(m,{...t}):e.jsxs("div",{className:`mb-4 archframe-card p-[22px] ${i??""}`,children:[r===3&&a&&e.jsx("div",{className:"mb-1.5 text-[19px] font-semibold tracking-[-0.01em] text-[color:var(--ink)]",children:a}),r===3&&s&&e.jsx("p",{className:"mb-[18px] text-sm text-[color:var(--muted-foreground)]",children:s}),e.jsx(m,{...t})]})}function P(){return e.jsx("section",{className:"section",children:e.jsxs(o,{children:[e.jsx(l,{eyebrow:"SDK examples",title:"Working code for real scenarios.",lead:"Every example in Python, TypeScript, and Go — switch languages on each snippet."}),e.jsxs("div",{className:"mt-6 space-y-6",children:[e.jsx(n,{level:3,title:"Initialize & Store a Memory",description:"Create the client, then write your first memory with actor scope + metadata.",window:{snippets:{py:`# pip install smritea-sdk
107
108from smritea import SmriteaClient
109from smritea.types import MemoryScope
110
111client = SmriteaClient(
112    api_key=os.getenv("SMRITEA_API_KEY"),
113    app_id=os.getenv("SMRITEA_APP_ID"),
114)
115
116# Store a memory — entity extraction happens automatically.
117# One call can extract multiple facts, so add() returns all of them.
118result = client.add(
119    "User prefers dark mode and compact UI layouts",
120    scope=MemoryScope(actor_id="user-123", actor_type="user"),
121    metadata={"category": "ui_preferences", "source": "settings-page"},
122)
123
124print(f"Stored {result.facts_extracted} memories:")
125for memory in result.memories:
126    print(f"  {memory.id}: {memory.content}")`,ts:`// npm install smritea-sdk
127
128import { SmriteaClient } from 'smritea-sdk';
129
130const client = new SmriteaClient({
131  apiKey: process.env.SMRITEA_API_KEY!,
132  appId: process.env.SMRITEA_APP_ID!,
133});
134
135// Store a memory — entity extraction happens automatically.
136// One call can extract multiple facts, so add() returns all of them.
137const result = await client.add(
138  "User prefers dark mode and compact UI layouts",
139  {
140    scope: { actorId: "user-123", actorType: "user" },
141    metadata: { category: "ui_preferences", source: "settings-page" },
142  }
143);
144
145console.log('Stored', result.factsExtracted, 'memories:');
146result.memories.forEach(m => console.log(' ', m.id, m.content));`,go:`// go get github.com/SmrutAI/smritea-sdk/go
147
148client := smritea.NewClient(smritea.ClientConfig{
149    APIKey: os.Getenv("SMRITEA_API_KEY"),
150    AppID:  os.Getenv("SMRITEA_APP_ID"),
151})
152
153// Store a memory — entity extraction happens automatically.
154// One call can extract multiple facts, so Add() returns all of them.
155result, err := client.Add(ctx, "User prefers dark mode and compact UI layouts",
156    smritea.NewAddOptions().
157        WithScope(smritea.NewMemoryScope().WithActorID("user-123").WithActorType("user")).
158        WithMetadata(map[string]any{"category": "ui_preferences", "source": "settings-page"}))
159
160fmt.Println("Stored", result.GetFactsExtracted(), "memories:")
161for _, m := range result.Memories {
162    fmt.Println(" ", m.GetId(), m.GetContent())
163}`},defaultLang:"py"}}),e.jsx(n,{level:3,title:"Search Memories",description:"Ways to search one actor's memories — plain and graph-aware.",window:{snippets:{py:`from smritea.types import MemoryScope
164
165scope = MemoryScope(actor_id="user-123", actor_type="user")
166
167# Basic search — hybrid vector + BM25
168results = client.search("What are the user's interface preferences?", scope=scope, limit=5)
169
170# Graph-aware search — traverses entity relationships
171deep = client.search("What else do we know about this user?", scope=scope, graph_depth=2)
172
173for r in results:
174    print(f"{r.score:.2f} {r.memory.content}")`,ts:`// Basic search — hybrid vector + BM25
175const results = await client.search(
176  "What are the user's interface preferences?",
177  { scope: { actorId: "user-123", actorType: "user" }, limit: 5 }
178);
179
180// Graph-aware search — traverses entity relationships
181const deep = await client.search(
182  "What else do we know about this user?",
183  { scope: { actorId: "user-123", actorType: "user" }, graphDepth: 2 }
184);
185
186results.forEach(r => console.log(r.score?.toFixed(2), r.memory?.content));`,go:`scope := smritea.NewMemoryScope().WithActorID("user-123").WithActorType("user")
187
188// Basic search — hybrid vector + BM25
189results, err := client.Search(ctx, "What are the user's interface preferences?",
190    smritea.NewSearchOptions().WithScope(scope).WithLimit(5))
191
192// Graph-aware search — traverses entity relationships
193deep, err := client.Search(ctx, "What else do we know about this user?",
194    smritea.NewSearchOptions().WithScope(scope).WithGraphDepth(2))
195
196for _, r := range results {
197    fmt.Println(r.GetScore(), r.Memory.GetContent())
198}`},defaultLang:"py"}}),e.jsx("p",{className:"text-[15px] text-[color:var(--muted-foreground)]",children:"What comes back — the real response shape from add() and search() (assuming the memories exist):"}),e.jsx("div",{className:"archframe-card p-4",children:e.jsx(m,{label:"response",snippets:{json:`// add("User prefers dark mode and compact UI layouts") →
199{
200  "memories": [
201    { "id": "mem_7f3a9c2e", "content": "User prefers dark mode",
202      "scope": { "actor_id": "user-123", "actor_type": "user" },
203      "metadata": { "category": "ui_preferences", "source": "settings-page" } },
204    { "id": "mem_b81d4f60", "content": "User prefers compact UI layouts",
205      "scope": { "actor_id": "user-123", "actor_type": "user" },
206      "metadata": { "category": "ui_preferences", "source": "settings-page" } }
207  ],
208  "facts_extracted": 2, "skipped_count": 0, "updated_count": 0
209}
210
211// search("What are the user's interface preferences?") →
212{
213  "memories": [
214    { "score": 0.93, "memory": { "id": "mem_7f3a9c2e", "content": "User prefers dark mode",
215        "scope": { "actor_id": "user-123", "actor_type": "user" } } },
216    { "score": 0.88, "memory": { "id": "mem_b81d4f60", "content": "User prefers compact UI layouts" } }
217  ]
218}`},showCopy:!1})}),e.jsx(n,{level:3,title:"Conversation Context",description:"Store both sides of a chat under one conversationId, then search within it.",window:{snippets:{py:`from smritea.types import MemoryScope
219
220conv = MemoryScope(actor_id="user-123", actor_type="user", conversation_id="conv-456")
221
222# Store turns from a conversation
223client.add("User: Can you switch the app to dark mode?", scope=conv)
224client.add(
225    "Assistant: Done — dark mode is on.",
226    scope=MemoryScope(actor_id="assistant-1", actor_type="agent", conversation_id="conv-456"),
227)
228
229# Search within this conversation
230context = client.search("What did the user ask about?", scope=conv)`,ts:`// Store turns from a conversation
231await client.add("User: Can you switch the app to dark mode?", {
232  scope: { actorId: "user-123", actorType: "user", conversationId: "conv-456" },
233});
234
235await client.add("Assistant: Done — dark mode is on.", {
236  scope: { actorId: "assistant-1", actorType: "agent", conversationId: "conv-456" },
237});
238
239// Search within this conversation
240const context = await client.search(
241  "What did the user ask about?",
242  { scope: { actorId: "user-123", actorType: "user", conversationId: "conv-456" } }
243);`,go:`conv := smritea.NewMemoryScope().
244    WithActorID("user-123").WithActorType("user").WithConversationID("conv-456")
245
246// Store turns from a conversation
247client.Add(ctx, "User: Can you switch the app to dark mode?",
248    smritea.NewAddOptions().WithScope(conv))
249client.Add(ctx, "Assistant: Done — dark mode is on.",
250    smritea.NewAddOptions().WithScope(smritea.NewMemoryScope().
251        WithActorID("assistant-1").WithActorType("agent").WithConversationID("conv-456")))
252
253// Search within this conversation
254context, err := client.Search(ctx, "What did the user ask about?",
255    smritea.NewSearchOptions().WithScope(conv))`},defaultLang:"py"}}),e.jsx(n,{level:3,title:"Error Handling & Rate Limits",description:"Catch the typed errors — not-found, rate-limit, validation.",window:{snippets:{py:`from smritea import (
256    SmriteaClient, SmriteaTooManyRequestsError,
257    SmriteaNotFoundError, SmriteaBadRequestError,
258)
259
260try:
261    memory = client.get("mem_nonexistent")
262except SmriteaNotFoundError as e:
263    print(f"Not found: {e.http_status}")
264except SmriteaTooManyRequestsError as e:
265    # SDK retries automatically (2x by default); fires after retries exhausted
266    print(f"Rate limited. Retry after: {e.retry_after}s")
267except SmriteaBadRequestError as e:
268    print(f"Bad request: {e.message}")`,ts:`import {
269  SmriteaClient, SmriteaTooManyRequestsError,
270  SmriteaBadRequestError, SmriteaNotFoundError,
271} from 'smritea-sdk';
272
273try {
274  const memory = await client.get("mem_nonexistent");
275} catch (err) {
276  if (err instanceof SmriteaNotFoundError) {
277    console.log("Memory not found:", err.httpStatus);
278  } else if (err instanceof SmriteaTooManyRequestsError) {
279    // SDK retries automatically (2x by default); fires after retries exhausted
280    console.log("Rate limited. Retry after:", err.retryAfter, "seconds");
281  } else if (err instanceof SmriteaBadRequestError) {
282    console.log("Bad request:", err.message);
283  }
284}`,go:`import (
285    "errors"
286    "fmt"
287    smritea "github.com/SmrutAI/smritea-sdk/go"
288)
289
290_, err := client.Get(ctx, "mem_nonexistent")
291if err != nil {
292    var notFound *smritea.SmriteaNotFoundError
293    var rateLimit *smritea.SmriteaTooManyRequestsError
294    var badRequest *smritea.SmriteaBadRequestError
295    switch {
296    case errors.As(err, &notFound):
297        fmt.Println("Memory not found:", notFound.HTTPStatus)
298    case errors.As(err, &rateLimit):
299        // SDK retries automatically (2x by default); fires after retries exhausted
300        retryAfter := 0
301        if rateLimit.RetryAfter != nil {
302            retryAfter = *rateLimit.RetryAfter
303        }
304        fmt.Println("Rate limited. Retry after:", retryAfter)
305    case errors.As(err, &badRequest):
306        fmt.Println("Bad request:", badRequest.Message)
307    }
308}`},defaultLang:"py"}}),e.jsx(n,{level:3,title:"Fetch & Delete a Memory",description:"Read a memory by its id, or remove it — ids come from add()'s response.",window:{snippets:{py:`# Fetch a memory by its id
309memory = client.get("mem_b81d4f60")
310print(memory.content)
311
312# Delete it when it's no longer needed
313client.delete("mem_b81d4f60")`,ts:`// Fetch a memory by its id
314const memory = await client.get("mem_b81d4f60");
315console.log(memory.content);
316
317// Delete it when it's no longer needed
318await client.delete("mem_b81d4f60");`,go:`// Fetch a memory by its id
319memory, err := client.Get(ctx, "mem_b81d4f60")
320fmt.Println(memory.GetContent())
321
322// Delete it when it's no longer needed
323err = client.Delete(ctx, "mem_b81d4f60")`},defaultLang:"py"}}
323)]})]})})}function M(){return e.jsx("section",{className:"section",children:e.jsx(o,{children:e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsx(p,{value:"4",valueTone:"ink",label:e.jsxs(e.Fragment,{children:["SDK methods: ",e.jsx("span",{className:"font-mono",children:"add · search · get · delete"})]})}),e.jsx(p,{value:"3",valueTone:"ink",label:"Search strategies (quick / deep / context-aware)"}),e.jsx(p,{value:"Auto",valueTone:"ink",label:e.jsxs(e.Fragment,{children:["Entity extraction & graph linking on every ",e.jsx("span",{className:"font-mono",children:"add()"})]})})]})})})}function E(){return e.jsx("section",{className:"section",children:e.jsxs(o,{children:[e.jsx(l,{eyebrow:"MCP server",title:"For Claude, Cursor & AI assistants.",lead:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono",children:"smritea-mcp"})," is a Model Context Protocol server that exposes memory tools to AI assistants — store and search as part of the conversation flow."]})}),e.jsx(n,{level:3,title:"Run the MCP server",description:"Initialize credentials, then start the server in stdio mode for Claude Code or SSE mode for Cursor.",window:{snippets:{bash:`# Initialize (saves credentials to ~/.smritea/mcp-config.json)
324npx -y smritea-mcp init
325
326# Start in stdio mode (Claude Code)
327npx -y smritea-mcp serve
328
329# Start in SSE mode (Cursor, port 3000)
330npx -y smritea-mcp serve-sse`},defaultLang:"bash",showCopy:!0}}),e.jsxs("div",{className:"mt-3.5 flex flex-wrap gap-2",children:[e.jsx("span",{className:"rounded-full border border-[color:var(--line)] bg-[var(--wash)] px-[11px] py-[5px] font-mono text-xs",children:"add_memory"}),e.jsx("span",{className:"rounded-full border border-[color:var(--line)] bg-[var(--wash)] px-[11px] py-[5px] font-mono text-xs",children:"search_memories"}),e.jsx("span",{className:"rounded-full border border-[color:var(--line)] bg-[var(--wash)] px-[11px] py-[5px] font-mono text-xs",children:"get_memory"}),e.jsx("span",{className:"rounded-full border border-[color:var(--line)] bg-[var(--wash)] px-[11px] py-[5px] font-mono text-xs",children:"delete_memory"}),e.jsx("span",{className:"rounded-full border border-[color:var(--line)] bg-[var(--wash)] px-[11px] py-[5px] font-mono text-xs",children:"select_app"}),e.jsx("span",{className:"rounded-full border border-[color:var(--line)] bg-[var(--wash)] px-[11px] py-[5px] font-mono text-xs",children:"list_apps"})]})]})})}function T(){return e.jsx("section",{className:"section",children:e.jsxs(o,{children:[e.jsx(l,{eyebrow:"Claude Code plugin",title:"Memory that loads itself.",lead:e.jsxs(e.Fragment,{children:["The ",e.jsx("span",{className:"font-mono",children:"smritea"})," plugin adds a SessionStart hook that fetches relevant memories and injects them as context automatically — plus commands to log in, save memories, and recall. Also works in Cursor."]})}),e.jsx(n,{level:3,title:"Install and use the plugin",description:"Clone the public plugin repo, load it into Claude Code, then run the Smritea commands inside Claude Code.",window:{tabs:[{id:"install",label:"Install",lang:"bash",code:`/plugin marketplace add SmrutAI/smritea-plugin
331/plugin install smritea@smritea
332/reload-plugins`,badge:{text:"$",background:"#555"}},{id:"usage",label:"Usage",lang:"bash",code:`# And then in the Claude Code window ...
333
334❯ /smritea:login
335❯ /smritea:config
336❯ /smritea:add-memory user prefers interfaces layered design with clean architecture recommendations, where each layer has dependency injection with interfaces that can be swapped with different implementations/mocks as needed
337❯ /smritea:recall layered design`,badge:{text:"❯",background:"#555",fontSize:"10px"}}],defaultTabId:"install",showCopy:!0}}),e.jsxs("p",{className:"mt-3.5 text-[color:var(--muted-foreground)]",children:["Commands: ",e.jsx("span",{className:"font-mono",children:"/plugin marketplace add SmrutAI/smritea-plugin"})," · ",e.jsx("span",{className:"font-mono",children:"/plugin install smritea@smritea"})," · ",e.jsx("span",{className:"font-mono",children:"/reload-plugins"})," · ",e.jsx("span",{className:"font-mono",children:"/smritea:login"})," · ",e.jsx("span",{className:"font-mono",children:"/smritea:config"})," · ",e.jsx("span",{className:"font-mono",children:"/smritea:add-memory <text>"})," · ",e.jsx("span",{className:"font-mono",children:"/smritea:recall <topic>"})]})]})})}function h({title:r,body:a,actions:s,className:t}){return e.jsxs("div",{className:x("archframe-card p-[22px]",t),children:[e.jsx("h4",{className:"mb-1.5 text-[15px] font-semibold text-foreground",children:r}),e.jsx("p",{className:"mb-3.5 text-[13px] text-muted-foreground",children:a}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(i=>e.jsx(y,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:i.href,target:"_blank",rel:"noopener noreferrer",children:i.label})},i.href))})]})}function W(){return e.jsx("section",{className:"section",children:e.jsxs(o,{children:[e.jsx(v,{children:"Resources"}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsx(h,{title:"API Reference",body:"OpenAPI spec with all endpoints, request/response schemas, and error codes.",actions:[{label:"View Docs",href:"https://docs.smritea.ai/api"}]}),e.jsx(h,{title:"SDK on PyPI & npm",body:e.jsxs("span",{style:{lineHeight:"1.9"},children:[e.jsx("span",{className:"font-mono",children:"pip install smritea-sdk"}),e.jsx("br",{}),e.jsx("span",{className:"font-mono",children:"npm install smritea-sdk"}),e.jsx("br",{}),e.jsx("span",{className:"font-mono",children:"go get …/smritea-sdk/go"})]}),actions:[{label:"PyPI",href:"https://pypi.org/project/smritea-sdk/"},{label:"npm",href:"https://www.npmjs.com/package/smritea-sdk"}]}),e.jsx(h,{title:"Source on GitHub",body:"Open-source core, SDK, and MCP server.",actions:[{label:"View on GitHub",href:"https://github.com/SmrutAI"}]})]})]})})}function U(){return e.jsxs("div",{children:[e.jsx(j,{title:"Examples — Quickstart & Recipes",description:"From zero to memory in 5 minutes: get API keys, install the SDK, store with add(), and search with search(). Real TypeScript and Python code.",path:"/examples"}),e.jsx(S,{}),e.jsx(A,{}),e.jsx(I,{}),e.jsx(C,{}),e.jsx(P,{}),e.jsx(M,{}),e.jsx(E,{}),e.jsx(T,{}),e.jsx(W,{}),e.jsx(b,{title:"Ready to try it?",body:"Get your API key and start storing memories.",ctaLabel:"Create Account"})]})}
337export{U as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.