From 6ad50da3f02da981d8e127f9a0ab34eaf749923f Mon Sep 17 00:00:00 2001 From: "J.J. Allaire" Date: Thu, 19 Sep 2024 09:50:11 -0400 Subject: [PATCH 1/2] fix mistral tool calling --- src/inspect_ai/model/_providers/mistral.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inspect_ai/model/_providers/mistral.py b/src/inspect_ai/model/_providers/mistral.py index c34d34eca..4688b27e1 100644 --- a/src/inspect_ai/model/_providers/mistral.py +++ b/src/inspect_ai/model/_providers/mistral.py @@ -179,11 +179,11 @@ def mistral_chat_tools(tools: list[ToolInfo]) -> list[MistralTool]: def mistral_chat_tool_choice( tool_choice: ToolChoice, -) -> ChatCompletionRequestToolChoice: +) -> str | dict[str, Any]: if isinstance(tool_choice, ToolFunction): return MistralToolChoice( type="function", function=FunctionName(name=tool_choice.name) - ) + ).model_dump() elif tool_choice == "any": return "any" elif tool_choice == "auto": From f6c4b739e621e846f4d5b9c5f0d9b13de0bca632 Mon Sep 17 00:00:00 2001 From: "J.J. Allaire" Date: Thu, 19 Sep 2024 09:58:15 -0400 Subject: [PATCH 2/2] mistral lint --- src/inspect_ai/model/_providers/mistral.py | 1 - tests/tools/test_tools.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/inspect_ai/model/_providers/mistral.py b/src/inspect_ai/model/_providers/mistral.py index 4688b27e1..d66d1f827 100644 --- a/src/inspect_ai/model/_providers/mistral.py +++ b/src/inspect_ai/model/_providers/mistral.py @@ -3,7 +3,6 @@ from typing import Any from mistralai import ( - ChatCompletionRequestToolChoice, FunctionCall, FunctionName, Mistral, diff --git a/tests/tools/test_tools.py b/tests/tools/test_tools.py index 6c5289840..f30bf5b02 100644 --- a/tests/tools/test_tools.py +++ b/tests/tools/test_tools.py @@ -77,7 +77,9 @@ async def add(x: int, y: int): return add -def check_tools(model: Model, disable: list[str] = ["calls", "force", "none"]) -> None: +def check_tools( + model: Model, disable: list[Literal["calls", "force", "none"]] = [] +) -> None: if "calls" not in disable: check_tools_calls(model) if "force" not in disable: @@ -171,7 +173,7 @@ def test_anthropic_tools(): @skip_if_no_mistral def test_mistral_tools(): - check_tools("mistral/mistral-large-latest", disable=["force"]) + check_tools("mistral/mistral-large-latest") @skip_if_no_groq