Merge pull request #1258 from Wei-Jianan/fix/cstream_not_work

[fix] stream field in llmconfig not work
This commit is contained in:
Alexander Wu 2024-05-17 15:39:08 +08:00 committed by GitHub
commit c20073e4bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View file

@ -74,7 +74,7 @@ class LLMConfig(YamlModel):
frequency_penalty: float = 0.0
best_of: Optional[int] = None
n: Optional[int] = None
stream: bool = False
stream: bool = True
# https://cookbook.openai.com/examples/using_logprobs
logprobs: Optional[bool] = None
top_logprobs: Optional[int] = None

View file

@ -132,7 +132,7 @@ class BaseLLM(ABC):
format_msgs: Optional[list[dict[str, str]]] = None,
images: Optional[Union[str, list[str]]] = None,
timeout=USE_CONFIG_TIMEOUT,
stream=True,
stream=None,
) -> str:
if system_msgs:
message = self._system_msgs(system_msgs)
@ -146,6 +146,8 @@ class BaseLLM(ABC):
message.append(self._user_msg(msg, images=images))
else:
message.extend(msg)
if stream is None:
stream = self.config.stream
logger.debug(message)
rsp = await self.acompletion_text(message, stream=stream, timeout=self.get_timeout(timeout))
return rsp