mirror of
https://github.com/giancarloerra/socraticode.git
synced 2026-07-03 14:05:21 +02:00
332ee800a8
LM Studio's Local Server speaks the OpenAI-compatible /v1/embeddings protocol, so users running it as their model host (chat plus embedding in one desktop app, GGUF model management) had no clean integration path. Changes: - src/services/provider-lmstudio.ts: new LMStudioEmbeddingProvider wrapping the OpenAI SDK with a custom baseURL (default http://localhost:1234/v1). Sends a placeholder API key to satisfy the OpenAI SDK while LM Studio's Local Server runs without auth by default. Skips the dimensions parameter because LM Studio models have no Matryoshka projection. Forces encoding_format=float to defeat the OpenAI SDK 6.x base64 default, which would otherwise mangle LM Studio's plain-array responses into 1024 zeros. - src/services/embedding-config.ts: extends the EmbeddingProvider union, reads LMSTUDIO_URL and LMSTUDIO_API_KEY, fail-fast validation when EMBEDDING_PROVIDER=lmstudio without EMBEDDING_MODEL or EMBEDDING_DIMENSIONS. - src/services/embedding-provider.ts: factory case for lmstudio with a dynamic import to avoid loading the OpenAI SDK at startup for ollama users. - ensureReady distinguishes "LM Studio unreachable" from "reachable but embedding model not loaded" so the operator knows whether to start the Local Server or load the configured model. - src/services/qdrant.ts: minor refactor to extract the hybrid-search query payload to a local const for readability. - README.md: dedicated LM Studio section, MCP host config example, env-var table entries. - tests/unit/embedding-config.test.ts: 8 new cases (required-env validation, URL default and override, optional API key, context-length override). - tests/unit/embedding-provider.test.ts: 3 new cases (factory wiring, ensureReady error format against a closed port, healthCheck unreachable output). Backward compatible. The lmstudio provider is opt-in via EMBEDDING_PROVIDER=lmstudio. Existing ollama, openai, and google paths are untouched.