diff --git a/libs/community/langchain_community/chat_models/sparkllm.py b/libs/community/langchain_community/chat_models/sparkllm.py index b29467108eb..9305b0ce378 100644 --- a/libs/community/langchain_community/chat_models/sparkllm.py +++ b/libs/community/langchain_community/chat_models/sparkllm.py @@ -306,15 +306,12 @@ class _SparkLLMClient: "wss://spark-api.xf-yun.com/v3.1/chat" if not api_url else api_url ) self.app_id = app_id - self.ws_url = _SparkLLMClient._create_url( - self.api_url, - api_key, - api_secret, - ) self.model_kwargs = model_kwargs self.spark_domain = spark_domain or "generalv3" self.queue: Queue[Dict] = Queue() self.blocking_message = {"content": "", "role": "assistant"} + self.api_key = api_key + self.api_secret = api_secret @staticmethod def _create_url(api_url: str, api_key: str, api_secret: str) -> str: @@ -370,7 +367,11 @@ class _SparkLLMClient: ) -> None: self.websocket_client.enableTrace(False) ws = self.websocket_client.WebSocketApp( - self.ws_url, + _SparkLLMClient._create_url( + self.api_url, + self.api_key, + self.api_secret, + ), on_message=self.on_message, on_error=self.on_error, on_close=self.on_close, diff --git a/libs/community/langchain_community/llms/sparkllm.py b/libs/community/langchain_community/llms/sparkllm.py index 7d5eeab2184..f2735f108d0 100644 --- a/libs/community/langchain_community/llms/sparkllm.py +++ b/libs/community/langchain_community/llms/sparkllm.py @@ -203,15 +203,12 @@ class _SparkLLMClient: "wss://spark-api.xf-yun.com/v3.1/chat" if not api_url else api_url ) self.app_id = app_id - self.ws_url = _SparkLLMClient._create_url( - self.api_url, - api_key, - api_secret, - ) self.model_kwargs = model_kwargs self.spark_domain = spark_domain or "generalv3" self.queue: Queue[Dict] = Queue() self.blocking_message = {"content": "", "role": "assistant"} + self.api_key = api_key + self.api_secret = api_secret @staticmethod def _create_url(api_url: str, api_key: str, api_secret: str) -> str: @@ -267,7 +264,11 @@ class _SparkLLMClient: ) -> None: self.websocket_client.enableTrace(False) ws = self.websocket_client.WebSocketApp( - self.ws_url, + _SparkLLMClient._create_url( + self.api_url, + self.api_key, + self.api_secret, + ), on_message=self.on_message, on_error=self.on_error, on_close=self.on_close,