Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

fixbug: qianfan timeout

莘权 马5bec4bbaa0fd
diff --git a/metagpt/provider/qianfan_api.py b/metagpt/provider/qianfan_api.py
index 04334f305..3ada7908d 100644
--- a/metagpt/provider/qianfan_api.py
+++ b/metagpt/provider/qianfan_api.py
@@ -106,13 +106,13 @@ class QianFanLLM(BaseLLM):
def get_choice_text(self, resp: JsonBody) -> str:
return resp.get("result", "")
- def completion(self, messages: list[dict]) -> JsonBody:
- resp = self.aclient.do(**self._const_kwargs(messages=messages, stream=False))
+ def completion(self, messages: list[dict], timeout: int = USE_CONFIG_TIMEOUT) -> JsonBody:
+ resp = self.aclient.do(**self._const_kwargs(messages=messages, stream=False), request_timeout=timeout)
self._update_costs(resp.body.get("usage", {}))
return resp.body
async def _achat_completion(self, messages: list[dict], timeout: int = USE_CONFIG_TIMEOUT) -> JsonBody:
- resp = await self.aclient.ado(**self._const_kwargs(messages=messages, stream=False))
+ resp = await self.aclient.ado(**self._const_kwargs(messages=messages, stream=False), request_timeout=timeout)
self._update_costs(resp.body.get("usage", {}))
return resp.body
@@ -120,7 +120,7 @@ class QianFanLLM(BaseLLM):
return await self._achat_completion(messages, timeout=self.get_timeout(timeout))
async def _achat_completion_stream(self, messages: list[dict], timeout: int = USE_CONFIG_TIMEOUT) -> str:
- resp = await self.aclient.ado(**self._const_kwargs(messages=messages, stream=True))
+ resp = await self.aclient.ado(**self._const_kwargs(messages=messages, stream=True), request_timeout=timeout)
collected_content = []
usage = {}
async for chunk in resp: