# langchain-mistralai
This package contains the LangChain integrations for [MistralAI](https://docs.mistral.ai) through their [mistralai](https://pypi.org/project/mistralai/) SDK.
## Installation
```bash
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.
```bash
export MISTRAL_API_KEY=your-api-key
```
Then initialize
```python
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:
```python
# 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"])`
Raw data
{
"_id": null,
"home_page": "https://github.com/langchain-ai/langchain",
"name": "langchain-mistralai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/82/74/ec18e3d7c02b8e95a21643d03ba075cca47c25584a9d5ff6a5d79ea2eda0/langchain_mistralai-0.2.4.tar.gz",
"platform": null,
"description": "# langchain-mistralai\n\nThis package contains the LangChain integrations for [MistralAI](https://docs.mistral.ai) through their [mistralai](https://pypi.org/project/mistralai/) SDK.\n\n## Installation\n\n```bash\npip install -U langchain-mistralai\n```\n\n## Chat Models\n\nThis package contains the `ChatMistralAI` class, which is the recommended way to interface with MistralAI models.\n\nTo use, install the requirements, and configure your environment.\n\n```bash\nexport MISTRAL_API_KEY=your-api-key\n```\n\nThen initialize\n\n```python\nfrom langchain_core.messages import HumanMessage\nfrom langchain_mistralai.chat_models import ChatMistralAI\n\nchat = ChatMistralAI(model=\"mistral-small\")\nmessages = [HumanMessage(content=\"say a brief hello\")]\nchat.invoke(messages)\n```\n\n`ChatMistralAI` also supports async and streaming functionality:\n\n```python\n# For async...\nawait chat.ainvoke(messages)\n\n# For streaming...\nfor chunk in chat.stream(messages):\n print(chunk.content, end=\"\", flush=True)\n```\n\n## Embeddings\n\nWith `MistralAIEmbeddings`, you can directly use the default model 'mistral-embed', or set a different one if available.\n\n### Choose model\n\n`embedding.model = 'mistral-embed'`\n\n### Simple query\n\n`res_query = embedding.embed_query(\"The test information\")`\n\n### Documents\n\n`res_document = embedding.embed_documents([\"test1\", \"another test\"])`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An integration package connecting Mistral and LangChain",
"version": "0.2.4",
"project_urls": {
"Homepage": "https://github.com/langchain-ai/langchain",
"Release Notes": "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-mistralai%3D%3D0%22&expanded=true",
"Repository": "https://github.com/langchain-ai/langchain",
"Source Code": "https://github.com/langchain-ai/langchain/tree/master/libs/partners/mistralai"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7cf3a4d6c69b74ce04644cfd37fc37a6b2ac7166dc990a61138825c983327a28",
"md5": "ff38b87faa9e2619579668f2684e48f1",
"sha256": "06b66c5bd9b69e17cd4dc74df77b22c1ec058ee1d0f3b4e2b7159ea3d38ab98e"
},
"downloads": -1,
"filename": "langchain_mistralai-0.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ff38b87faa9e2619579668f2684e48f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 15207,
"upload_time": "2024-12-18T22:41:38",
"upload_time_iso_8601": "2024-12-18T22:41:38.940992Z",
"url": "https://files.pythonhosted.org/packages/7c/f3/a4d6c69b74ce04644cfd37fc37a6b2ac7166dc990a61138825c983327a28/langchain_mistralai-0.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8274ec18e3d7c02b8e95a21643d03ba075cca47c25584a9d5ff6a5d79ea2eda0",
"md5": "cce1f7e812772d26fb2ae7b512f62241",
"sha256": "defc9befd7bf26a14e491950a2b3427b8f2d575c917851d665520848ae960055"
},
"downloads": -1,
"filename": "langchain_mistralai-0.2.4.tar.gz",
"has_sig": false,
"md5_digest": "cce1f7e812772d26fb2ae7b512f62241",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 14220,
"upload_time": "2024-12-18T22:41:41",
"upload_time_iso_8601": "2024-12-18T22:41:41.093875Z",
"url": "https://files.pythonhosted.org/packages/82/74/ec18e3d7c02b8e95a21643d03ba075cca47c25584a9d5ff6a5d79ea2eda0/langchain_mistralai-0.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-18 22:41:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "langchain-ai",
"github_project": "langchain",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "langchain-mistralai"
}