(name: string = "sparc2-vector-store")
| 64 | * @returns The vector store ID |
| 65 | */ |
| 66 | export 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 |
no outgoing calls
no test coverage detected