# 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/d4/6c/436691d6c1bc3de30a039f4156a9e21b317faff2a8758d5024de47b9aecf/langchain_mistralai-0.2.1.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.1",
"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": "2dda4f3e1fac86301fefd91780f28ece32766b8b4e88b246a37252827023f0fc",
"md5": "8d8bb5444939b29d3132a8467d97b51f",
"sha256": "77d79f339f11e96cb8e433160c1abe6f88ee7a8582c2f82a9412a49e3a036664"
},
"downloads": -1,
"filename": "langchain_mistralai-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d8bb5444939b29d3132a8467d97b51f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 14844,
"upload_time": "2024-10-31T18:33:03",
"upload_time_iso_8601": "2024-10-31T18:33:03.638908Z",
"url": "https://files.pythonhosted.org/packages/2d/da/4f3e1fac86301fefd91780f28ece32766b8b4e88b246a37252827023f0fc/langchain_mistralai-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d46c436691d6c1bc3de30a039f4156a9e21b317faff2a8758d5024de47b9aecf",
"md5": "53cd6b658c04b20535863f3e76520f12",
"sha256": "cd1553396b96cce8d8e8972a6f10bf257ea303d345339a7055504901930daa82"
},
"downloads": -1,
"filename": "langchain_mistralai-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "53cd6b658c04b20535863f3e76520f12",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 13933,
"upload_time": "2024-10-31T18:33:04",
"upload_time_iso_8601": "2024-10-31T18:33:04.544182Z",
"url": "https://files.pythonhosted.org/packages/d4/6c/436691d6c1bc3de30a039f4156a9e21b317faff2a8758d5024de47b9aecf/langchain_mistralai-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-31 18:33:04",
"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"
}