Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/run_example_scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions examples/mistral/chat/async_chat_with_image_no_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
7 changes: 5 additions & 2 deletions examples/mistral/chat/async_structured_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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__":
Expand Down
3 changes: 2 additions & 1 deletion src/mistralai/extra/observability/redaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading