Skip to main content

An integration package connecting Mistral and GigaChain

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)

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"])

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

gigachain_mistralai-0.1.9.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

gigachain_mistralai-0.1.9-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file gigachain_mistralai-0.1.9.tar.gz.

File metadata

  • Download URL: gigachain_mistralai-0.1.9.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/23.5.0

File hashes

Hashes for gigachain_mistralai-0.1.9.tar.gz
Algorithm Hash digest
SHA256 07b2096465cf775819fcdd458c950c9e8e718b8d23e2ef1eb438a695b2c074b5
MD5 3049253e953a18fb7b5a498703411980
BLAKE2b-256 eb38e219a5b032cbe486ca33f728fa6a1be55424f71061c48793c10df54da93a

See more details on using hashes here.

File details

Details for the file gigachain_mistralai-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for gigachain_mistralai-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 06c519af9c8da37ae150a9baf21db9b148bf72f690a968aef6a586593f4f2521
MD5 458d189c72353c4683b63dc1253d7f4e
BLAKE2b-256 a2b4ab3afd389085b591b81cbb63589c8ad78ab44b3f3e19c9ad60e32c17fde7

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