The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
mistral[patch]: set global ssl context (#30189)
ccurmeb209d46eb3ab
diff --git a/libs/partners/mistralai/langchain_mistralai/chat_models.py b/libs/partners/mistralai/langchain_mistralai/chat_models.pyindex 01692b7d87..98aa414e57 100644--- a/libs/partners/mistralai/langchain_mistralai/chat_models.py+++ b/libs/partners/mistralai/langchain_mistralai/chat_models.py@@ -5,6 +5,7 @@ import jsonimport loggingimport osimport re+import sslimport uuidfrom operator import itemgetterfrom typing import (@@ -24,6 +25,7 @@ from typing import (cast,)+import certifiimport httpxfrom httpx_sse import EventSource, aconnect_sse, connect_ssefrom langchain_core.callbacks import (@@ -87,6 +89,11 @@ logger = logging.getLogger(__name__)TOOL_CALL_ID_PATTERN = re.compile(r"^[a-zA-Z0-9]{9}$")+# This SSL context is equivelent to the default `verify=True`.+# https://www.python-httpx.org/advanced/ssl/#configuring-client-instances+global_ssl_context = ssl.create_default_context(cafile=certifi.where())++def _create_retry_decorator(llm: ChatMistralAI,run_manager: Optional[@@ -518,6 +525,7 @@ class ChatMistralAI(BaseChatModel):"Authorization": f"Bearer {api_key_str}",},timeout=self.timeout,+ verify=global_ssl_context,)# todo: handle retries and max_concurrencyif not self.async_client:@@ -529,6 +537,7 @@ class ChatMistralAI(BaseChatModel):"Authorization": f"Bearer {api_key_str}",},timeout=self.timeout,+ verify=global_ssl_context,)if self.temperature is not None and not 0 <= self.temperature <= 1: