From 42008498037d805eb03334c166c0e1b6268a6860 Mon Sep 17 00:00:00 2001 From: jjallaire Date: Fri, 7 Mar 2025 11:03:37 +0000 Subject: [PATCH] Update to new Mistral API (v1.5.1 of `mistralai` is now required) (#1444) --- CHANGELOG.md | 1 + src/inspect_ai/model/_providers/mistral.py | 3 +++ src/inspect_ai/model/_providers/providers.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba747d5e..4ee709c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - More consistent use of `max_retries` and `timeout` configuration options. These options now exclusively control Inspect's outer retry handler; model providers use their default behaviour for the inner request, which is typically 2-4 retries and a service-appropriate timeout. - Improved async implementation using AnyIO (can now optionally run Trio rather than asyncio as the [async backend](https://inspect.ai-safety-institute.org.uk/parallelism.html#async-backends)). - Model API: `ChatMessage` now includes an `id` field (defaults to auto-generated uuid). +- Mistral: Update to new Mistral API (v1.5.1 of `mistralai` is now required). - Logging: Inspect no longer sets the global log level nor does it allow its own messages to propagate to the global handler (eliminating the possiblity of duplicate display). This should improve compatibility with applications that have their own custom logging configured. - Tasks: For filesystem based tasks, no longer switch to the task file's directory during execution (directory switching still occurs during task loading). Specify `@task(chdir=True)` to preserve the previous behavior. - Bugfix: Fix issue with deserializing custom sandbox configuration objects. diff --git a/src/inspect_ai/model/_providers/mistral.py b/src/inspect_ai/model/_providers/mistral.py index 46185d096..e361c69b3 100644 --- a/src/inspect_ai/model/_providers/mistral.py +++ b/src/inspect_ai/model/_providers/mistral.py @@ -7,6 +7,7 @@ from httpx import ReadTimeout as AsyncReadTimeout from mistralai import ( ContentChunk, + DocumentURLChunk, FunctionCall, FunctionName, ImageURL, @@ -475,6 +476,8 @@ def completion_content_chunk(content: ContentChunk) -> Content: raise TypeError("ReferenceChunk content is not supported by Inspect.") elif isinstance(content, TextChunk): return ContentText(text=content.text) + elif isinstance(content, DocumentURLChunk): + return ContentText(text=content.document_url) else: if isinstance(content.image_url, str): return ContentImage(image=content.image_url) diff --git a/src/inspect_ai/model/_providers/providers.py b/src/inspect_ai/model/_providers/providers.py index dfb8118cf..de25f61ad 100644 --- a/src/inspect_ai/model/_providers/providers.py +++ b/src/inspect_ai/model/_providers/providers.py @@ -148,7 +148,7 @@ def cf() -> type[ModelAPI]: def mistral() -> type[ModelAPI]: FEATURE = "Mistral API" PACKAGE = "mistralai" - MIN_VERSION = "1.5.0" + MIN_VERSION = "1.5.1" # verify we have the package try: