{"record":{"id":"7a8860efe96aaacf","repo":"CherryHQ/cherry-studio","slug":"local-embedding-provider-only-supports-text-embedd","errorCode":null,"errorMessage":"local-embedding provider only supports text embeddings, not ${capability}","messagePattern":"local-embedding provider only supports text embeddings, not (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ai/provider/custom/localEmbedding/localEmbeddingProvider.ts","lineNumber":53,"sourceCode":"  /**\n   * Unused in-process (no HTTP), but the shared provider config builder does\n   * `config.providerSettings.fetch ??= customFetch` across the settings union,\n   * so every member must carry this field. See `provider/config.ts`.\n   */\n  fetch?: FetchFunction\n}\n\n/**\n * Embedding-only `ProviderV3`. Language / image models throw, since this\n * provider exists solely to serve the knowledge base's local text embeddings.\n */\n// `_settings` is unused (in-process provider, no config) but its type is how the\n// extension registry infers this provider's settings type — keep the parameter.\n// oxlint-disable-next-line no-unused-vars\nexport function createLocalEmbeddingProvider(_settings: LocalEmbeddingProviderSettings = {}): ProviderV3 {\n  const embeddingModel = (modelId: string): EmbeddingModelV3 => new LocalEmbeddingModel(modelId)\n  const unsupported = (capability: string) => (): never => {\n    throw new Error(`local-embedding provider only supports text embeddings, not ${capability}`)\n  }\n\n  return {\n    specificationVersion: 'v3',\n    embeddingModel,\n    textEmbeddingModel: embeddingModel,\n    languageModel: unsupported('language models') as (modelId: string) => LanguageModelV3,\n    imageModel: unsupported('image models') as (modelId: string) => ImageModelV3\n  }\n}\n","sourceCodeStart":35,"sourceCodeEnd":64,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/provider/custom/localEmbedding/localEmbeddingProvider.ts#L35-L64","documentation":"Thrown by the local-embedding provider when `languageModel` or `imageModel` is called. This provider is embedding-only by design — it exists solely to serve the knowledge base's local text embeddings via transformers.js. The `unsupported` helper throws immediately to make the capability boundary explicit rather than returning a model that would fail later.","triggerScenarios":"Calling `provider.languageModel(id)` or `provider.imageModel(id)` on a provider created by `createLocalEmbeddingProvider`; or a model-routing layer dispatching a chat/image request to the local-embedding provider id.","commonSituations":"A model was tagged with the local-embedding provider id in config but referenced for chat/image; a routing table fell back to the wrong provider; a test reused the local provider for a non-embedding call.","solutions":["Use the local-embedding provider only for text embeddings (`embeddingModel` / `textEmbeddingModel`).","Route chat and image requests to a provider that supports them (OpenAI, DashScope, etc.).","Fix the model/provider mapping that misrouted a non-embedding call here."],"exampleFix":"// before\nconst model = localProvider.languageModel('bge-m3') // throws\n// after\nconst model = localProvider.textEmbeddingModel('bge-m3')","handlingStrategy":"type-guard","validationCode":"if (providerId === LOCAL_EMBEDDING_PROVIDER_ID && capability !== 'embedding') {\n  throw new Error(`local-embedding only supports embeddings — route ${capability} elsewhere`)\n}","typeGuard":"const supportsCapability = (providerId: string, capability: 'embedding' | 'language' | 'image'): boolean =>\n  providerId !== LOCAL_EMBEDDING_PROVIDER_ID || capability === 'embedding'","tryCatchPattern":null,"preventionTips":["Keep the local-embedding provider out of chat/image routing tables","Tag local-embedding models as embedding-only in the model registry","Test that misrouting throws a clear message"],"tags":["unsupported-feature","local-embedding","capability","routing"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}