Instrumentation for Mistral AI's python client: see Mistral API doc for reference.
I validated the change against with Chainlit's use of the instrumentation and adjusted our RAG documentation app to rely on Mistral AI (except embeddings). There were a few changes because Mistral doesn't support [type: text, content: ""] format, but it worked otherwise. In the following video you'll notice that the streaming and the tool calls don't show, I believe it's due to my local setup (I have RAG app -> depends on chainlit -> depends on literalai and I'm not sure about the whole build setup).
You'll notice that prompt playground settings show mistral-tiny, when it should be mistral-large-latest. It's a bug on our Literal platform:
chat() + FIM (fill in the middle) completion() endpoints
sync and async
streamed or not
To test:
install this version of literalai with pip install .
you need a Mistral API key - ask me (or there might be a way to setup MistralClient to talk directly to an LM studio inference server)
the below MWE should show a generation in "My initial project" on staging (and it should stream in your notebook!)
check that the model, provider, settings do show in the Generation details
try out the "Context Relevancy with Ragas" and make sure that you have the ability to jump to the prompt
try out tools with the "Agent runs - Evaluation" cookbook
import os
from literalai import LiteralClient
from mistralai.client import MistralClient
lai_client = LiteralClient(api_key="my-initial-api-key", url="https://staging.chainlit.io/")
lai_client.instrument_mistralai()
mai_client = MistralClient(api_key="the-secret-api-key")
stream = mai_client.chat_stream(
model="open-mistral-7b",
messages=[{"role": "user", "content": "🖖 Qui est Camille Saint-Saëns ? 🎵"}],
)
for part in stream:
if token := part.choices[0].delta.content or "":
print(token, end="")
Worth-noting changes:
move to Python 3.9 on the CI tests: everything but the Mistral AI instrumentation should work in the SDK
instrumentation for OpenAI and Mistral AI should work simultaneously
removal of unnecessary yield in chat if condition (in streaming_response)
rely on .message.content in completion API instead of .text
no need to test Azure client because they didn't create a separate client, they just point to the Azure endpoint
Mistral AI instrumentation
Instrumentation for Mistral AI's python client: see Mistral API doc for reference.
I validated the change against with Chainlit's use of the instrumentation and adjusted our RAG documentation app to rely on Mistral AI (except embeddings). There were a few changes because Mistral doesn't support [type: text, content: ""] format, but it worked otherwise. In the following video you'll notice that the streaming and the tool calls don't show, I believe it's due to my local setup (I have RAG app -> depends on chainlit -> depends on literalai and I'm not sure about the whole build setup).
You'll notice that prompt playground settings show mistral-tiny, when it should be mistral-large-latest. It's a bug on our Literal platform:
https://www.loom.com/share/6d139bfbe18a4aaf92dcde27bf466a41
Features:
To test:
literalai
withpip install .
Worth-noting changes:
yield
in chat if condition (in streaming_response).message.content
in completion API instead of.text