The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]: Fix the error of Baidu Qianfan not passing the stop parameter (#18666)
ligang-supera662468ddeeb
diff --git a/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.py b/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.pyindex e91c8b7c56..801364c4df 100644--- a/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.py+++ b/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.py@@ -271,6 +271,7 @@ class QianfanChatEndpoint(BaseChatModel):},)params = self._convert_prompt_msg_params(messages, **kwargs)+ params["stop"] = stopresponse_payload = self.client.do(**params)lc_msg = _convert_dict_to_message(response_payload)gen = ChatGeneration(@@ -316,6 +317,7 @@ class QianfanChatEndpoint(BaseChatModel):},)params = self._convert_prompt_msg_params(messages, **kwargs)+ params["stop"] = stopresponse_payload = await self.client.ado(**params)lc_msg = _convert_dict_to_message(response_payload)generations = []@@ -339,6 +341,7 @@ class QianfanChatEndpoint(BaseChatModel):**kwargs: Any,) -> Iterator[ChatGenerationChunk]:params = self._convert_prompt_msg_params(messages, **kwargs)+ params["stop"] = stopparams["stream"] = Truefor res in self.client.do(**params):if res:@@ -365,6 +368,7 @@ class QianfanChatEndpoint(BaseChatModel):**kwargs: Any,) -> AsyncIterator[ChatGenerationChunk]:params = self._convert_prompt_msg_params(messages, **kwargs)+ params["stop"] = stopparams["stream"] = Trueasync for res in await self.client.ado(**params):if res:diff --git a/libs/community/langchain_community/llms/baidu_qianfan_endpoint.py b/libs/community/langchain_community/llms/baidu_qianfan_endpoint.pyindex 2ef7baba68..1a611d2656 100644--- a/libs/community/langchain_community/llms/baidu_qianfan_endpoint.py+++ b/libs/community/langchain_community/llms/baidu_qianfan_endpoint.py@@ -180,6 +180,7 @@ class QianfanLLMEndpoint(LLM):completion += chunk.textreturn completionparams = self._convert_prompt_msg_params(prompt, **kwargs)+ params["stop"] = stopresponse_payload = self.client.do(**params)return response_payload["result"]@@ -198,6 +199,7 @@ class QianfanLLMEndpoint(LLM):return completionparams = self._convert_prompt_msg_params(prompt, **kwargs)+ params["stop"] = stopresponse_payload = await self.client.ado(**params)return response_payload["result"]@@ -210,6 +212,7 @@ class QianfanLLMEndpoint(LLM):**kwargs: Any,) -> Iterator[GenerationChunk]:params = self._convert_prompt_msg_params(prompt, **{**kwargs, "stream": True})+ params["stop"] = stopfor res in self.client.do(**params):if res:chunk = GenerationChunk(text=res["result"])@@ -225,6 +228,7 @@ class QianfanLLMEndpoint(LLM):**kwargs: Any,) -> AsyncIterator[GenerationChunk]:params = self._convert_prompt_msg_params(prompt, **{**kwargs, "stream": True})+ params["stop"] = stopasync for res in await self.client.ado(**params):if res:chunk = GenerationChunk(text=res["result"])