Skip to content

The agent engineering platform.

mistralai: release 0.1.5, allow client passing in (#21034)

Erick Friis854ae3e1de43
diff --git a/libs/partners/mistralai/langchain_mistralai/chat_models.py b/libs/partners/mistralai/langchain_mistralai/chat_models.py
index a00943d2c0..04ccbeb436 100644
--- a/libs/partners/mistralai/langchain_mistralai/chat_models.py
+++ b/libs/partners/mistralai/langchain_mistralai/chat_models.py
@@ -408,25 +408,27 @@ class ChatMistralAI(BaseChatModel):
)
api_key_str = values["mistral_api_key"].get_secret_value()
# todo: handle retries
- values["client"] = httpx.Client(
- base_url=values["endpoint"],
- headers={
- "Content-Type": "application/json",
- "Accept": "application/json",
- "Authorization": f"Bearer {api_key_str}",
- },
- timeout=values["timeout"],
- )
+ if not values.get("client"):
+ values["client"] = httpx.Client(
+ base_url=values["endpoint"],
+ headers={
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+ "Authorization": f"Bearer {api_key_str}",
+ },
+ timeout=values["timeout"],
+ )
# todo: handle retries and max_concurrency
- values["async_client"] = httpx.AsyncClient(
- base_url=values["endpoint"],
- headers={
- "Content-Type": "application/json",
- "Accept": "application/json",
- "Authorization": f"Bearer {api_key_str}",
- },
- timeout=values["timeout"],
- )
+ if not values.get("async_client"):
+ values["async_client"] = httpx.AsyncClient(
+ base_url=values["endpoint"],
+ headers={
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+ "Authorization": f"Bearer {api_key_str}",
+ },
+ timeout=values["timeout"],
+ )
if values["temperature"] is not None and not 0 <= values["temperature"] <= 1:
raise ValueError("temperature must be in the range [0.0, 1.0]")
diff --git a/libs/partners/mistralai/langchain_mistralai/embeddings.py b/libs/partners/mistralai/langchain_mistralai/embeddings.py
index 268918a9f9..f2f8067bd1 100644
--- a/libs/partners/mistralai/langchain_mistralai/embeddings.py
+++ b/libs/partners/mistralai/langchain_mistralai/embeddings.py
@@ -75,25 +75,27 @@ class MistralAIEmbeddings(BaseModel, Embeddings):
)
api_key_str = values["mistral_api_key"].get_secret_value()
# todo: handle retries
- values["client"] = httpx.Client(
- base_url=values["endpoint"],
- headers={
- "Content-Type": "application/json",
- "Accept": "application/json",
- "Authorization": f"Bearer {api_key_str}",
- },
- timeout=values["timeout"],
- )
+ if not values.get("client"):
+ values["client"] = httpx.Client(
+ base_url=values["endpoint"],
+ headers={
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+ "Authorization": f"Bearer {api_key_str}",
+ },
+ timeout=values["timeout"],
+ )
# todo: handle retries and max_concurrency
- values["async_client"] = httpx.AsyncClient(
- base_url=values["endpoint"],
- headers={
- "Content-Type": "application/json",
- "Accept": "application/json",
- "Authorization": f"Bearer {api_key_str}",
- },
- timeout=values["timeout"],
- )
+ if not values.get("async_client"):
+ values["async_client"] = httpx.AsyncClient(
+ base_url=values["endpoint"],
+ headers={
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+ "Authorization": f"Bearer {api_key_str}",
+ },
+ timeout=values["timeout"],
+ )
if values["tokenizer"] is None:
try:
values["tokenizer"] = Tokenizer.from_pretrained(
diff --git a/libs/partners/mistralai/poetry.lock b/libs/partners/mistralai/poetry.lock
index 16b4ffda3d..83fbd9a029 100644
--- a/libs/partners/mistralai/poetry.lock
+++ b/libs/partners/mistralai/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
[[package]]
name = "annotated-types"
@@ -190,13 +190,13 @@ test = ["pytest (>=6)"]
[[package]]
name = "filelock"
-version = "3.13.4"
+version = "3.14.0"
description = "A platform independent file lock."
optional = false
python-versions = ">=3.8"
files = [
- {file = "filelock-3.13.4-py3-none-any.whl", hash = "sha256:404e5e9253aa60ad457cae1be07c0f0ca90a63931200a47d9b6a6af84fd7b45f"},
- {file = "filelock-3.13.4.tar.gz", hash = "sha256:d13f466618bfde72bd2c18255e269f72542c6e70e7bac83a0232d6b1cc5c8cf4"},
+ {file = "filelock-3.14.0-py3-none-any.whl", hash = "sha256:43339835842f110ca7ae60f1e1c160714c5a6afd15a2873419ab185334975c0f"},
+ {file = "filelock-3.14.0.tar.gz", hash = "sha256:6ea72da3be9b8c82afd3edcf99f2fffbb5076335a5ae4d03248bb5b6c3eae78a"},
]
[package.extras]
@@ -430,13 +430,13 @@ url = "../../standard-tests"
[[package]]
name = "langsmith"
-version = "0.1.50"
+version = "0.1.51"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
optional = false
python-versions = "<4.0,>=3.8.1"
files = [
- {file = "langsmith-0.1.50-py3-none-any.whl", hash = "sha256:a81e9809fcaa277bfb314d729e58116554f186d1478fcfdf553b1c2ccce54b85"},
- {file = "langsmith-0.1.50.tar.gz", hash = "sha256:9fd22df8c689c044058536ea5af66f5302067e7551b60d7a335fede8d479572b"},
+ {file = "langsmith-0.1.51-py3-none-any.whl", hash = "sha256:1e7363a3f472ecf02a1d91f6dbacde25519554b98c490be71716fcffaab0ca6b"},
+ {file = "langsmith-0.1.51.tar.gz", hash = "sha256:b99b40a8c00e66174540865caa61412622fa1dc4f02602965364919c90528f97"},
]
[package.dependencies]
@@ -725,13 +725,13 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no
[[package]]
name = "pytest-asyncio"
-version = "0.21.1"
+version = "0.21.2"
description = "Pytest support for asyncio"
optional = false
python-versions = ">=3.7"
files = [
- {file = "pytest-asyncio-0.21.1.tar.gz", hash = "sha256:40a7eae6dded22c7b604986855ea48400ab15b069ae38116e8c01238e9eeb64d"},
- {file = "pytest_asyncio-0.21.1-py3-none-any.whl", hash = "sha256:8666c1c8ac02631d7c51ba282e0c69a8a452b211ffedf2599099845da5c5c37b"},
+ {file = "pytest_asyncio-0.21.2-py3-none-any.whl", hash = "sha256:ab664c88bb7998f711d8039cacd4884da6430886ae8bbd4eded552ed2004f16b"},
+ {file = "pytest_asyncio-0.21.2.tar.gz", hash = "sha256:d67738fc232b94b326b9d060750beb16e0074210b98dd8b58a5239fa2a154f45"},
]
[package.dependencies]
diff --git a/libs/partners/mistralai/pyproject.toml b/libs/partners/mistralai/pyproject.toml
index c4ad9a41b3..fcedafbc86 100644
--- a/libs/partners/mistralai/pyproject.toml
+++ b/libs/partners/mistralai/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langchain-mistralai"
-version = "0.1.4"
+version = "0.1.5"
description = "An integration package connecting Mistral and LangChain"
authors = []
readme = "README.md"