diff --git a/core/llm/toolSupport.test.ts b/core/llm/toolSupport.test.ts index 308d3ae7e..7d68e8615 100644 --- a/core/llm/toolSupport.test.ts +++ b/core/llm/toolSupport.test.ts @@ -288,17 +288,38 @@ describe("PROVIDER_TOOL_SUPPORT", () => { expect(supportsFn("mistral-7b")).toBe(true); }); + it("should return true for LM Studio hyphenated model IDs", () => { + // LM Studio uses hyphenated model identifiers like "Meta-Llama-3.1-8B-Instruct-GGUF" + expect(supportsFn("Meta-Llama-3.1-8B-Instruct-GGUF")).toBe(true); + expect(supportsFn("Meta-Llama-3.2-3B-Instruct")).toBe(true); + expect(supportsFn("Qwen2-7B-Instruct")).toBe(true); + expect(supportsFn("Mixtral-8x7B-Instruct-v0.1")).toBe(true); + expect(supportsFn("Mistral-7B-Instruct-v0.2")).toBe(true); + expect(supportsFn("llama-3.1-8b-instruct")).toBe(true); + }); + it("should return false for explicitly unsupported models (same as ollama)", () => { expect(supportsFn("vision")).toBe(false); expect(supportsFn("math")).toBe(false); expect(supportsFn("guard")).toBe(false); }); + it("should return false for hyphenated unsupported model names", () => { + expect(supportsFn("Llama-Vision-Free")).toBe(false); + expect(supportsFn("Math-Solver-7B")).toBe(false); + expect(supportsFn("Guard-Model")).toBe(false); + }); + it("should handle case insensitivity (same as ollama)", () => { expect(supportsFn("LLAMA3.1")).toBe(true); expect(supportsFn("MIXTRAL-8x7b")).toBe(true); expect(supportsFn("VISION")).toBe(false); }); + + it("should handle case insensitivity with hyphenated names", () => { + expect(supportsFn("META-LLAMA-3.1-8B-INSTRUCT")).toBe(true); + expect(supportsFn("Qwen2-7B-Instruct-GGUF")).toBe(true); + }); }); describe("xAI", () => { diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index 818626c6a..79302717b 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -189,7 +189,12 @@ export const PROVIDER_TOOL_SUPPORT: Record boolean> = return false; }, - lmstudio: (model) => PROVIDER_TOOL_SUPPORT["ollama"](model), + lmstudio: (model) => { + // LM Studio uses hyphenated model IDs (e.g., "Meta-Llama-3.1-8B-Instruct-GGUF") + // Convert to format that matches Ollama's heuristic (e.g., "llama3.1") + const normalized = model.toLowerCase().replace(/-/g, ""); + return PROVIDER_TOOL_SUPPORT["ollama"](normalized); + }, sambanova: (model) => { // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling if (