langchain-mistralai
This package contains the LangChain integrations for MistralAI through their mistralai SDK.
Installation
pip install -U langchain-mistralai
Chat Models
This package contains the ChatMistralAI class, which is the recommended way to interface with MistralAI models.
To use, install the requirements, and configure your environment.
export MISTRAL_API_KEY=your-api-key
Then initialize
from langchain_core.messages import HumanMessage
from langchain_mistralai.chat_models import ChatMistralAI
chat = ChatMistralAI(model="mistral-small")
messages = [HumanMessage(content="say a brief hello")]
chat.invoke(messages)
ChatMistralAI also supports async and streaming functionality:
# For async...
await chat.ainvoke(messages)
# For streaming...
for chunk in chat.stream(messages):
print(chunk.content, end="", flush=True)
Embeddings
With MistralAIEmbeddings, you can directly use the default model 'mistral-embed', or set a different one if available.
Choose model
embedding.model = 'mistral-embed'
Simple query
res_query = embedding.embed_query("The test information")
Documents
res_document = embedding.embed_documents(["test1", "another test"])
Metadata
Release files for langchain-mistralai 0.2.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_mistralai-0.2.11.tar.gz | 21.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_mistralai-0.2.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.3 kB
Release files / langchain_mistralai-0.2.11.tar.gz
| Download URL | langchain_mistralai-0.2.11.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0816bb9972c9e407d9eca567ad16095ec4f0f5bb9094890692ceb149aa72c71e
|
|
BLAKE2b-256 checksum How to use checksums |
6df57afd7dcd252e5abaaf3a13849733a32aaf0b5f2290dc62bd2c72afdc33e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / langchain_mistralai-0.2.11-py3-none-any.whl
| Download URL | langchain_mistralai-0.2.11-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6940b551f8e63ca9163e8f5a156aab6814238f9b19302405b6af9d8703e7f762
|
|
BLAKE2b-256 checksum How to use checksums |
4835cf2e31b5af5b6798437bb7c92b13d0ed7c4bdde87034227b49be907fe272
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|