Skip to main content

An integration package connecting Mistral and LangChain

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_mistralai-0.0.2.post1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file langchain_mistralai-0.0.2.post1.tar.gz.

File metadata

File hashes

Hashes for langchain_mistralai-0.0.2.post1.tar.gz
Algorithm Hash digest
SHA256 485c9d2483536b9d48edcea54c74b6bd3227f5c3b9422ab7fa61fcfc935d1589
MD5 e64eccb1a91a23d0a9366d45de5c2d38
BLAKE2b-256 26d4d7b907df10b72e5cbd3ed8c682fa1b399b43b65d5cdf0b3a0bb4baa83d90

See more details on using hashes here.

File details

Details for the file langchain_mistralai-0.0.2.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_mistralai-0.0.2.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0005cc94e87f511d8631e67e310ff96091c3e0ee621949aa24cfeb02f02fce3
MD5 b1c14431b3a6d4fa44b20a29770aa137
BLAKE2b-256 03be3c7ac306673f7b699199a53e99ad47dc7b8d9f504e0114a2ec124310091e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page