Name | openinference-instrumentation-mistralai JSON |
Version |
1.1.2
JSON |
| download |
home_page | None |
Summary | OpenInference Mistral AI Instrumentation |
upload_time | 2025-02-05 22:24:25 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <3.14,>=3.9 |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# OpenInference Mistral AI Instrumentation
[](https://pypi.python.org/pypi/openinference-instrumentation-mistralai)
Python autoinstrumentation library for MistralAI's Python SDK.
The traces emitted by this instrumentation are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as [`arize-phoenix`](https://github.com/Arize-ai/phoenix)
## Installation
```shell
pip install openinference-instrumentation-mistralai
```
## Quickstart
In this example we will instrument a small program that uses the MistralAI chat completions API and observe the traces via [`arize-phoenix`](https://github.com/Arize-ai/phoenix).
Install packages.
```shell
pip install openinference-instrumentation-mistralai mistralai arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp
```
Start the phoenix server so that it is ready to collect traces.
The Phoenix server runs entirely on your machine and does not send data over the internet.
```shell
python -m phoenix.server.main serve
```
In a python file, setup the `MistralAIInstrumentor` and configure the tracer to send traces to Phoenix.
```python
from mistralai.client import MistralClient
from mistralai.models.chat_completion import ChatMessage
from openinference.instrumentation.mistralai import MistralAIInstrumentor
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
endpoint = "http://127.0.0.1:6006/v1/traces"
tracer_provider = trace_sdk.TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
# Optionally, you can also print the spans to the console.
tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace_api.set_tracer_provider(tracer_provider)
MistralAIInstrumentor().instrument()
if __name__ == "__main__":
client = MistralClient()
response = client.chat(
model="mistral-large-latest",
messages=[
ChatMessage(
content="Who won the World Cup in 2018?",
role="user",
)
],
)
print(response.choices[0].message.content)
```
Since we are using MistralAI, we must set the `MISTRAL_API_KEY` environment variable to authenticate with the MistralAI API.
```shell
export MISTRAL_API_KEY=[your_key_here]
```
Now simply run the python file and observe the traces in Phoenix.
```shell
python your_file.py
```
## More Info
* [More info on OpenInference and Phoenix](https://docs.arize.com/phoenix)
* [How to customize spans to track sessions, metadata, etc.](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#customizing-spans)
* [How to account for private information and span payload customization](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#tracing-configuration)
Raw data
{
"_id": null,
"home_page": null,
"name": "openinference-instrumentation-mistralai",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "OpenInference Authors <oss@arize.com>",
"download_url": "https://files.pythonhosted.org/packages/cb/d9/c7ddd8afc728fba29b7cafa7f56bf801b32538a7e5525b94acbe76789d2a/openinference_instrumentation_mistralai-1.1.2.tar.gz",
"platform": null,
"description": "# OpenInference Mistral AI Instrumentation\n[](https://pypi.python.org/pypi/openinference-instrumentation-mistralai) \n\nPython autoinstrumentation library for MistralAI's Python SDK.\n\nThe traces emitted by this instrumentation are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as [`arize-phoenix`](https://github.com/Arize-ai/phoenix)\n\n## Installation\n\n```shell\npip install openinference-instrumentation-mistralai\n```\n\n## Quickstart\n\nIn this example we will instrument a small program that uses the MistralAI chat completions API and observe the traces via [`arize-phoenix`](https://github.com/Arize-ai/phoenix).\n\nInstall packages.\n\n```shell\npip install openinference-instrumentation-mistralai mistralai arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp\n```\n\nStart the phoenix server so that it is ready to collect traces.\nThe Phoenix server runs entirely on your machine and does not send data over the internet.\n\n```shell\npython -m phoenix.server.main serve\n```\n\nIn a python file, setup the `MistralAIInstrumentor` and configure the tracer to send traces to Phoenix.\n\n```python\nfrom mistralai.client import MistralClient\nfrom mistralai.models.chat_completion import ChatMessage\nfrom openinference.instrumentation.mistralai import MistralAIInstrumentor\nfrom opentelemetry import trace as trace_api\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk import trace as trace_sdk\nfrom opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor\n\nendpoint = \"http://127.0.0.1:6006/v1/traces\"\ntracer_provider = trace_sdk.TracerProvider()\ntracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))\n# Optionally, you can also print the spans to the console.\ntracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))\ntrace_api.set_tracer_provider(tracer_provider)\n\nMistralAIInstrumentor().instrument()\n\n\nif __name__ == \"__main__\":\n client = MistralClient()\n response = client.chat(\n model=\"mistral-large-latest\",\n messages=[\n ChatMessage(\n content=\"Who won the World Cup in 2018?\",\n role=\"user\",\n )\n ],\n )\n print(response.choices[0].message.content)\n\n```\n\nSince we are using MistralAI, we must set the `MISTRAL_API_KEY` environment variable to authenticate with the MistralAI API.\n\n```shell\nexport MISTRAL_API_KEY=[your_key_here]\n```\n\nNow simply run the python file and observe the traces in Phoenix.\n\n```shell\npython your_file.py\n```\n\n## More Info\n\n* [More info on OpenInference and Phoenix](https://docs.arize.com/phoenix)\n* [How to customize spans to track sessions, metadata, etc.](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#customizing-spans)\n* [How to account for private information and span payload customization](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#tracing-configuration)\n",
"bugtrack_url": null,
"license": null,
"summary": "OpenInference Mistral AI Instrumentation",
"version": "1.1.2",
"project_urls": {
"Homepage": "https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-mistralai"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6069954f57cacaabc3afe938b8490ddf657d411ed56ec6b00cbde1dda6b144e5",
"md5": "3160d150670a4654c432a7c75e838897",
"sha256": "af034911f0bb57e0163b9946642cd7de3ec92a8865f56ad580c5b0caf9ba0ea9"
},
"downloads": -1,
"filename": "openinference_instrumentation_mistralai-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3160d150670a4654c432a7c75e838897",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.9",
"size": 20036,
"upload_time": "2025-02-05T22:24:24",
"upload_time_iso_8601": "2025-02-05T22:24:24.541596Z",
"url": "https://files.pythonhosted.org/packages/60/69/954f57cacaabc3afe938b8490ddf657d411ed56ec6b00cbde1dda6b144e5/openinference_instrumentation_mistralai-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cbd9c7ddd8afc728fba29b7cafa7f56bf801b32538a7e5525b94acbe76789d2a",
"md5": "a658272239320fffbd89492acb699de4",
"sha256": "076bb47e8ac88a2924285058c6d5dab3593f97686cd5b2caa8286aa879bf931d"
},
"downloads": -1,
"filename": "openinference_instrumentation_mistralai-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "a658272239320fffbd89492acb699de4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.14,>=3.9",
"size": 21142,
"upload_time": "2025-02-05T22:24:25",
"upload_time_iso_8601": "2025-02-05T22:24:25.801444Z",
"url": "https://files.pythonhosted.org/packages/cb/d9/c7ddd8afc728fba29b7cafa7f56bf801b32538a7e5525b94acbe76789d2a/openinference_instrumentation_mistralai-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-05 22:24:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Arize-ai",
"github_project": "openinference",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "openinference-instrumentation-mistralai"
}