Repository navigation
Expand file tree
/
Copy pathconfig.ts
More file actions
73 lines (60 loc) · 3.33 KB
/
Copy pathconfig.ts
File metadata and controls
73 lines (60 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* One place for every value you might want to change.
*
* If you are reading the tutorial, this file is the "settings panel".
* Nothing here is clever. It is just names and numbers.
*/
// The database created inside your cluster.
export const DB_NAME = process.env.MEMORY_DB ?? "agent_memory";
// Two collections. One holds what was said, the other holds what it meant.
export const COLLECTIONS = {
// Every message, exactly as it was said. This is the transcript.
messages: "messages",
// Short facts the agent decided were worth keeping. This is the memory.
memories: "memories",
} as const;
// The MongoDB Vector Search index we create on the "memories" collection.
export const VECTOR_INDEX = "memory_vector_index";
// The Voyage AI model Atlas uses to embed facts.
//
// We never call an embedding API ourselves. The index declares this model with
// the "autoEmbed" field type, and Atlas generates the vector twice: once when
// we write a fact, and once for the query text on every recall. That means no
// embedding key in this app, and no dimensions to keep in sync, because the
// model is declared in one place and Atlas owns both sides of it.
export const EMBEDDING_MODEL = process.env.VOYAGE_MODEL ?? "voyage-4";
// The field Atlas embeds. This is the fact itself, not a separate vector field:
// with automated embedding you index the text and Atlas stores the vector for you.
export const EMBEDDING_PATH = "fact";
// Which model provider to use. "openai" also covers anything that speaks the
// same protocol, which includes a local Ollama, LM Studio, vLLM, Groq and
// Together. Point LLM_BASE_URL at those.
//
// These are functions rather than constants so they are read after dotenv has
// loaded, not at module import time.
export const LLM_PROVIDER = () => (process.env.LLM_PROVIDER ?? "anthropic").toLowerCase();
export const LLM_BASE_URL = () => process.env.LLM_BASE_URL;
// One capable model for the conversation, one small cheap one for deciding
// what is worth remembering.
const DEFAULT_MODELS: Record<string, { chat: string; extract: string }> = {
anthropic: { chat: "claude-sonnet-4-6", extract: "claude-haiku-4-5" },
openai: { chat: "gpt-4o", extract: "gpt-4o-mini" },
};
const defaultsFor = (role: "chat" | "extract") =>
(DEFAULT_MODELS[LLM_PROVIDER()] ?? DEFAULT_MODELS.anthropic)[role];
export const LLM_CHAT_MODEL = () => process.env.LLM_CHAT_MODEL ?? defaultsFor("chat");
export const LLM_EXTRACT_MODEL = () => process.env.LLM_EXTRACT_MODEL ?? defaultsFor("extract");
// Tagging your connection makes it easy to see this app in Atlas metrics and logs.
export const APP_NAME = "devrel.content.ephemeral-agent-memory";
// The Ephemeral Cluster creation endpoint.
// Override this with an environment variable so you never have to edit code when the URL changes.
export const EPHEMERAL_ENDPOINT =
process.env.ATLAS_EPHEMERAL_ENDPOINT ??
"https://cloud.mongodb.com/api/atlas/v2/unauth/ephemeralClusters:create";
export const EPHEMERAL_CLUSTER_NAME =
process.env.ATLAS_EPHEMERAL_CLUSTER_NAME ?? "Cluster0";
// The dated version header ("application/vnd.atlas.2025-03-12+json") now returns
// 406 INVALID_VERSION_DATE against the endpoint below. "preview" is what the
// unauth ephemeral endpoint currently accepts.
export const EPHEMERAL_ACCEPT_HEADER =
process.env.ATLAS_EPHEMERAL_ACCEPT ?? "application/vnd.atlas.preview+json";