Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix post v1.1 issues w/ mistral tool calling #457

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/inspect_ai/model/_providers/mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any

from mistralai import (
ChatCompletionRequestToolChoice,
FunctionCall,
FunctionName,
Mistral,
Expand Down Expand Up @@ -179,11 +178,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":
Expand Down
6 changes: 4 additions & 2 deletions tests/tools/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading