Co-authored-by: Quentin Torroba <quentin.torroba@mistral.ai>
Co-authored-by: Clement Sirieix <clem.sirieix@gmail.com>
Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Mathias Gesbert 2026-03-10 16:07:18 +01:00 committed by GitHub
parent dd372ce494
commit e9428bce23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 877 additions and 362 deletions

View file

@ -1,12 +1,13 @@
from __future__ import annotations
from unittest.mock import AsyncMock, patch
from unittest.mock import AsyncMock, MagicMock, patch
import mistralai
import pytest
from tests.mock.utils import collect_result
from vibe.core.tools.base import BaseToolState, ToolError
from vibe.core.config import Backend, ProviderConfig
from vibe.core.tools.base import BaseToolState, InvokeContext, ToolError
from vibe.core.tools.builtins.websearch import WebSearch, WebSearchArgs, WebSearchConfig
@ -151,6 +152,61 @@ async def test_run_sdk_error_wrapped(websearch):
await collect_result(websearch.run(WebSearchArgs(query="test")))
def test_resolve_server_url_no_ctx(websearch):
assert websearch._resolve_server_url(None) is None
def test_resolve_server_url_no_agent_manager(websearch):
ctx = InvokeContext(tool_call_id="t1", agent_manager=None)
assert websearch._resolve_server_url(ctx) is None
def test_resolve_server_url_with_mistral_provider(websearch):
config = MagicMock()
config.providers = [
ProviderConfig(
name="mistral",
api_base="https://on-prem.example.com/v1",
api_key_env_var="MISTRAL_API_KEY",
backend=Backend.MISTRAL,
)
]
agent_manager = MagicMock()
agent_manager.config = config
ctx = InvokeContext(tool_call_id="t1", agent_manager=agent_manager)
assert websearch._resolve_server_url(ctx) == "https://on-prem.example.com"
def test_resolve_server_url_with_default_provider(websearch):
config = MagicMock()
config.providers = [
ProviderConfig(
name="mistral",
api_base="https://api.mistral.ai/v1",
api_key_env_var="MISTRAL_API_KEY",
backend=Backend.MISTRAL,
)
]
agent_manager = MagicMock()
agent_manager.config = config
ctx = InvokeContext(tool_call_id="t1", agent_manager=agent_manager)
assert websearch._resolve_server_url(ctx) == "https://api.mistral.ai"
def test_resolve_server_url_no_mistral_provider(websearch):
config = MagicMock()
config.providers = [
ProviderConfig(name="llamacpp", api_base="http://127.0.0.1:8080/v1")
]
agent_manager = MagicMock()
agent_manager.config = config
ctx = InvokeContext(tool_call_id="t1", agent_manager=agent_manager)
assert websearch._resolve_server_url(ctx) is None
def test_is_available_with_key(monkeypatch):
monkeypatch.setenv("MISTRAL_API_KEY", "key")
assert WebSearch.is_available() is True