From 928cf2c73752a23fe3fc026bbf3957c5c80d5604 Mon Sep 17 00:00:00 2001 From: Minipeps Date: Mon, 14 Apr 2025 17:41:16 +0200 Subject: [PATCH 1/4] feat: add support for Mistral models in toolSupport.ts --- core/llm/toolSupport.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index 3d0d72cc8..de5566ff1 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -72,6 +72,17 @@ export const PROVIDER_TOOL_SUPPORT: Record< return true; } }, + mistral: (model) => { + // https://docs.mistral.ai/capabilities/function_calling/ + return [ + "codestral", + "mistral-large", + "mistral-small", + "pixtral", + "ministral", + "mistral-nemo" + ].some((part) => model.toLowerCase().includes(part)); + }, // https://ollama.com/search?c=tools ollama: (model) => { let modelName = ""; From aa30a826d832e73a782ce6642038b8e58cdc46b3 Mon Sep 17 00:00:00 2001 From: Minipeps Date: Mon, 14 Apr 2025 17:57:54 +0200 Subject: [PATCH 2/4] docs: update model-setup.mdx to include Mistral support --- docs/docs/agent/model-setup.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/agent/model-setup.mdx b/docs/docs/agent/model-setup.mdx index 89e1cdf7e..f0acf6f85 100644 --- a/docs/docs/agent/model-setup.mdx +++ b/docs/docs/agent/model-setup.mdx @@ -15,5 +15,6 @@ Currently the following providers are supported: - [Ollama](../customize/model-providers/top-level/ollama.mdx) - we recommend [Qwen 2.5 Coder 7b](https://hub.continue.dev/ollama/qwen2.5-coder-7b). Also see all Ollama models that support tools [here](https://ollama.com/search?c=tools). - [OpenAI](../customize/model-providers/top-level/openai.mdx) - we recommend [GPT-4o](https://hub.continue.dev/openai/gpt-4o) - [Gemini](../customize/model-providers/top-level/gemini.mdx) - we recommend [Gemini 2.0 Flash](https://hub.continue.dev/google/gemini-2.0-flash) +- [Mistral](../customize/model-providers/top-level/mistral.mdx) - we recommend [Codestral](https://hub.continue.dev/mistral/codestral) The best chat models generally support tool usage. See [recommended chat models](../customize/model-roles/chat.mdx#recommended-chat-models) for more. From 00ccae0384b4e9fe175c16edb085c4b29f6a5acd Mon Sep 17 00:00:00 2001 From: Minipeps Date: Tue, 15 Apr 2025 13:55:19 +0200 Subject: [PATCH 3/4] tests: add new llm and toolSupport tests for Mistral providers --- core/llm/llm.test.ts | 6 +++++- core/llm/toolSupport.test.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/core/llm/llm.test.ts b/core/llm/llm.test.ts index 2ce2d93b2..d1067a8bc 100644 --- a/core/llm/llm.test.ts +++ b/core/llm/llm.test.ts @@ -226,7 +226,11 @@ describe("LLM", () => { apiKey: process.env.MISTRAL_API_KEY, model: "codestral-latest", }), - { testFim: true, skip: false }, + { + testFim: true, + skip: false, + testToolCall: true, + }, ); testLLM( new Azure({ diff --git a/core/llm/toolSupport.test.ts b/core/llm/toolSupport.test.ts index df18dc876..c92bb93ee 100644 --- a/core/llm/toolSupport.test.ts +++ b/core/llm/toolSupport.test.ts @@ -143,6 +143,36 @@ describe("PROVIDER_TOOL_SUPPORT", () => { }); }); + describe("mistral", () => { + const supportsFn = PROVIDER_TOOL_SUPPORT["mistral"]; + + it("should return true for supported models", () => { + expect(supportsFn("mistral-large-latest")).toBe(true); + expect(supportsFn("mistral-small-latest")).toBe(true); + expect(supportsFn("codestral-latest")).toBe(true); + expect(supportsFn("ministral-8b-latest")).toBe(true); + expect(supportsFn("ministral-3b-latest")).toBe(true); + expect(supportsFn("pixtral-12b-2409")).toBe(true); + expect(supportsFn("pixtral-large-latest")).toBe(true); + expect(supportsFn("open-mistral-nemo")).toBe(true); + }); + + it("should return false for other unsupported models", () => { + expect(supportsFn("mistral-saba-latest")).toBe(false); + expect(supportsFn("mistral-embed")).toBe(false); + expect(supportsFn("mistral-moderation-latest")).toBe(false); + expect(supportsFn("mistral-ocr-latest")).toBe(false); + expect(supportsFn("open-codestral-mamba")).toBe(false); + }); + + it("should handle case insensitivity", () => { + expect(supportsFn("MISTRAL-LARGE-LATEST")).toBe(true); + expect(supportsFn("CODESTRAL-LATEST")).toBe(true); + expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true); + expect(supportsFn("PIXTRAL-12B-2409")).toBe(true); + }); + }); + describe("ollama", () => { const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"]; From c6591f836ea73e1244a0e965111f7c599669d9fa Mon Sep 17 00:00:00 2001 From: Minipeps Date: Tue, 15 Apr 2025 14:10:09 +0200 Subject: [PATCH 4/4] fix: exclude open-codestral-mamba from supported models --- core/llm/toolSupport.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index de5566ff1..4de0c251a 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -74,7 +74,8 @@ export const PROVIDER_TOOL_SUPPORT: Record< }, mistral: (model) => { // https://docs.mistral.ai/capabilities/function_calling/ - return [ + return !model.toLowerCase().includes("mamba") && + [ "codestral", "mistral-large", "mistral-small",