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.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

langchain_mistralai-0.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_mistralai-0.0.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for langchain_mistralai-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1e8396306b8f826d81b6e53e9f289770e440a80061aa3866d7039e26c450a2d1
MD5 abf34d08339ba3d127bd8b51f82038f9
BLAKE2b-256 bac26c65ede51d9c50355be212fa55e478702e18fefc387761657de8dff53689

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_mistralai-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 334ed39cf49642a0f6e93b8e8a3d178fff4ff325e6ffdeb44f38f3d065de0390
MD5 dd4e0bea7fae704ea095c2c6ffe156f8
BLAKE2b-256 ad91f12acd7e09fdfa31c238c9050f3da17e277984c4c4086f6d9e35d0b54f5d

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