MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / initializeVectorStore

Function initializeVectorStore

scripts/sparc2/src/vector/vectorStore.ts:66–93  ·  view source on GitHub ↗
(name: string = "sparc2-vector-store")

Source from the content-addressed store, hash-verified

64 * @returns The vector store ID
65 */
66export async function initializeVectorStore(name: string = "sparc2-vector-store"): Promise<string> {
67 try {
68 // If we already have a vector store ID, return it
69 if (vectorStoreId !== null) {
70 console.debug("Using existing vector store", { id: vectorStoreId });
71 return vectorStoreId as string;
72 }
73
74 // If OpenAI client is not available, use mock implementation
75 if (!openai) {
76 vectorStoreId = "mock-vector-store-id";
77 console.debug("Using mock vector store", { id: vectorStoreId });
78 return vectorStoreId;
79 }
80
81 // Create a new vector store
82 const vectorStore = await openai.vectorStores.create({ name });
83 vectorStoreId = vectorStore.id;
84
85 console.debug("Vector store initialized", { id: vectorStoreId });
86
87 return vectorStoreId as string;
88 } catch (error: unknown) {
89 console.debug("Failed to initialize vector store, using mock", { error: String(error) });
90 vectorStoreId = "mock-vector-store-id" as string;
91 return vectorStoreId;
92 }
93}
94
95/**
96 * Store a log entry in the vector database

Callers 4

vectorStoreLogFunction · 0.70
indexDiffEntryFunction · 0.70
searchDiffEntriesFunction · 0.70
searchLogEntriesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected