mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-10 00:02:38 +02:00
chore: 代码格式化
This commit is contained in:
parent
2a2380613d
commit
5afa7f045a
3 changed files with 15 additions and 10 deletions
|
|
@ -185,4 +185,3 @@ ## Citation
|
|||
primaryClass={cs.AI}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,7 @@ class GeneralAPIRequestor(APIRequestor):
|
|||
) -> Tuple[Union[bytes, AsyncGenerator[bytes, None]], bool]:
|
||||
content_type = result.headers.get("Content-Type", "")
|
||||
if stream and (
|
||||
"text/event-stream" in content_type or
|
||||
"application/x-ndjson" in content_type or
|
||||
content_type == ''
|
||||
"text/event-stream" in content_type or "application/x-ndjson" in content_type or content_type == ""
|
||||
):
|
||||
# the `Content-Type` of ollama stream resp is "application/x-ndjson"
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -51,9 +51,13 @@ class OllamaLLM(BaseLLM):
|
|||
return json.loads(chunk)
|
||||
|
||||
async def _achat_completion(self, messages: list[dict], timeout: int = USE_CONFIG_TIMEOUT) -> dict:
|
||||
headers = None if not self.config.api_key or self.config.api_key == "sk-" else {
|
||||
"Authorization": f"Bearer {self.config.api_key}",
|
||||
}
|
||||
headers = (
|
||||
None
|
||||
if not self.config.api_key or self.config.api_key == "sk-"
|
||||
else {
|
||||
"Authorization": f"Bearer {self.config.api_key}",
|
||||
}
|
||||
)
|
||||
resp, _, _ = await self.client.arequest(
|
||||
method=self.http_method,
|
||||
url=self.suffix_url,
|
||||
|
|
@ -70,9 +74,13 @@ class OllamaLLM(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:
|
||||
headers = None if not self.config.api_key or self.config.api_key == "sk-" else {
|
||||
"Authorization": f"Bearer {self.config.api_key}",
|
||||
}
|
||||
headers = (
|
||||
None
|
||||
if not self.config.api_key or self.config.api_key == "sk-"
|
||||
else {
|
||||
"Authorization": f"Bearer {self.config.api_key}",
|
||||
}
|
||||
)
|
||||
stream_resp, _, _ = await self.client.arequest(
|
||||
method=self.http_method,
|
||||
url=self.suffix_url,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue