ManimCat / src /knowledge /api-rag /index.ts
Bin29's picture
Deploy 5548f84: pre-sandbox v2.0.0-beta.1 snapshot
10dd572
Raw History Blame Contribute Delete
1.34 kB
import { ApiRagService } from './api-rag-service'
import { createMiniLmEmbedding } from './mini-lm-embedding'
import type { ApiCatalogPackage } from './types'
export * from './types'
export { ApiRagService, type ApiRagServiceOptions } from './api-rag-service'
/** Packages the product may answer for, in the order they are probed. */
export const API_RAG_PACKAGES: readonly ApiCatalogPackage[] = ['manim', 'matplotlib']
export function createApiRagService(
packages: readonly ApiCatalogPackage[] = API_RAG_PACKAGES
): ApiRagService {
return new ApiRagService({
embedding: createMiniLmEmbedding(),
packages
})
}
/**
* Registration is decided at construction (one synchronous file read per package), and `ready()`
* is the single asynchronous door that loads the Baselines and the SearchDoc matrix. The
* composition root builds the Tool registry at import time, so construction cannot be async.
*/
let apiRagService: ApiRagService | undefined
/**
* The process-wide instance. Studio Builder and Workflow Code Repair share this one
* Baseline index, SearchDoc matrix and MiniLM session; nothing constructs a second
* service per request or per repair attempt.
*/
export function getApiRagService(): ApiRagService {
if (!apiRagService) {
apiRagService = createApiRagService()
}
return apiRagService
}