socraticode
Version:
SocratiCode — MCP server for local codebase indexing, semantic search, and code dependency graphs. All private, all local via Docker.
49 lines • 2.63 kB
TypeScript
/**
* LiteLLM embedding provider.
*
* LiteLLM Proxy Server (https://docs.litellm.ai/docs/simple_proxy) exposes an
* OpenAI-compatible /v1/embeddings endpoint that fans out to 100+ underlying
* model providers (OpenAI, Anthropic, Cohere, Voyage, HuggingFace, Bedrock,
* Vertex AI, Ollama, ...). Model aliases are defined in the proxy's config.yaml,
* so from this client's perspective LiteLLM looks like an OpenAI server speaking
* arbitrary model names.
*
* This provider is intentionally separate from `provider-openai.ts` and
* `provider-lmstudio.ts` because:
* - LiteLLM ALWAYS requires an API key (virtual or master), unlike LM Studio.
* - Default port is 4000 and /v1/models lists proxy-registered aliases, not
* loaded local models.
* - Whether the `dimensions` parameter is honoured depends on the underlying
* provider chosen by the proxy alias, so we make it opt-in via
* LITELLM_SEND_DIMENSIONS instead of hardcoding it like provider-openai
* does for text-embedding-3-*.
* - Health check messaging points at proxy-side issues (master key, alias
* missing in config.yaml) rather than at SaaS quotas or local model loads.
*
* Required env when using this provider:
* EMBEDDING_PROVIDER=litellm
* LITELLM_API_KEY=<virtual-or-master-key>
* EMBEDDING_MODEL=<alias-from-litellm-config-yaml>
* EMBEDDING_DIMENSIONS=<dim-of-underlying-model>
*
* Optional env:
* LITELLM_URL=http://localhost:4000/v1 (default; must include /v1 suffix)
* LITELLM_SEND_DIMENSIONS=true (opt-in; forwards `dimensions` to the
* proxy for Matryoshka-aware models like
* text-embedding-3-* or voyage-3 routed
* via LiteLLM. Default false because
* non-Matryoshka backends raise on it.)
* EMBEDDING_CONTEXT_LENGTH=<tokens> (defaults to 2048 if model unknown)
*/
import type { EmbeddingHealthStatus, EmbeddingProvider, EmbeddingReadinessResult } from "./embedding-types.js";
/** Reset client (for testing or LITELLM_URL / LITELLM_API_KEY hot-swap). */
export declare function resetLiteLLMClient(): void;
export declare class LiteLLMEmbeddingProvider implements EmbeddingProvider {
readonly name = "litellm";
ensureReady(): Promise<EmbeddingReadinessResult>;
embed(texts: string[]): Promise<number[][]>;
embedSingle(text: string): Promise<number[]>;
healthCheck(): Promise<EmbeddingHealthStatus>;
private _embedBatch;
}
//# sourceMappingURL=provider-litellm.d.ts.map