diff --git a/.github/workflows/run_example_scripts.yaml b/.github/workflows/run_example_scripts.yaml index a14e83e4..ed182f0e 100644 --- a/.github/workflows/run_example_scripts.yaml +++ b/.github/workflows/run_example_scripts.yaml @@ -34,7 +34,7 @@ jobs: - name: Install client with extras run: | - PACKAGE="dist/$(ls dist | grep whl | head -n 1)[agents]" + PACKAGE="dist/$(ls dist | grep whl | head -n 1)[agents,telemetry]" uv pip install --system "$PACKAGE" examples: @@ -73,7 +73,7 @@ jobs: - name: Install client with extras and run all examples. run: | - PACKAGE="dist/$(ls dist | grep whl | head -n 1)[agents]" + PACKAGE="dist/$(ls dist | grep whl | head -n 1)[agents,telemetry]" uv pip install --system "$PACKAGE" ./scripts/run_examples.sh env: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7517b816..48061d24 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,7 @@ repos: rev: v1.1.401 hooks: - id: pyright + additional_dependencies: [pydantic] files: ^(examples/|src/mistralai/|packages/(azure|gcp)/src/mistralai/).*\.py$ exclude: ^src/mistralai/(__init__|sdkhooks|types)\.py$ - repo: https://github.com/pre-commit/mirrors-mypy diff --git a/examples/mistral/chat/async_chat_with_image_no_streaming.py b/examples/mistral/chat/async_chat_with_image_no_streaming.py index 5d2cbdaa..44bdd1b3 100755 --- a/examples/mistral/chat/async_chat_with_image_no_streaming.py +++ b/examples/mistral/chat/async_chat_with_image_no_streaming.py @@ -21,14 +21,17 @@ async def main(): {"type": "text", "text": "What's in this image?"}, { "type": "image_url", - "image_url": "https://cms.mistral.ai/assets/a64b3821-3a4c-4d4d-b718-d653f3eb7a5e.png?", + "image_url": "https://raw.githubusercontent.com/mistralai/mistral-common/7edf6f651b3579135f44686e345d51b7e19a536a/docs/assets/logo_favicon.png", }, ] ) ], ) - print(chat_response.choices[0].message.content) + if chat_response.choices: + message = chat_response.choices[0].message + if message is not None: + print(message.content) if __name__ == "__main__": diff --git a/examples/mistral/chat/async_structured_outputs.py b/examples/mistral/chat/async_structured_outputs.py index 09ed5737..3adfaf6f 100644 --- a/examples/mistral/chat/async_structured_outputs.py +++ b/examples/mistral/chat/async_structured_outputs.py @@ -20,7 +20,7 @@ class MathDemonstration(BaseModel): final_answer: str chat_response = await client.chat.parse_async( - model="mistral-large-2411", + model="mistral-large-latest", messages=[ { "role": "system", @@ -30,7 +30,10 @@ class MathDemonstration(BaseModel): ], response_format=MathDemonstration, ) - print(chat_response.choices[0].message.parsed) + if chat_response.choices: + message = chat_response.choices[0].message + if message is not None: + print(message.parsed) if __name__ == "__main__": diff --git a/src/mistralai/extra/observability/redaction.py b/src/mistralai/extra/observability/redaction.py index fe9319e6..dbd8e74a 100644 --- a/src/mistralai/extra/observability/redaction.py +++ b/src/mistralai/extra/observability/redaction.py @@ -29,7 +29,8 @@ # Inherit from the real base only for static analysis: linters verify our # export/shutdown/force_flush signatures. At runtime the base is object so # the optional OpenTelemetry SDK is not required to import this module. - _SpanExporterBase = SpanExporter + # Imported (not assigned to a variable) so type checkers accept it as a base. + from opentelemetry.sdk.trace.export import SpanExporter as _SpanExporterBase else: _SpanExporterBase = object