Refactor OpenAI class to use asynchronous room check for generating response.

- Replaced synchronous room check with asynchronous room check using `await`.
- Updated the code to use the `await` keyword before calling `self.room_uses_assistant(room)`.
- This change enables the code to generate assistant response asynchronously.
This commit is contained in:
Kumi 2023-11-19 16:15:28 +01:00
parent 65bf724a0b
commit c3fe074b1e
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -167,7 +167,7 @@ class OpenAI:
""" """
self.logger.log(f"Generating response to {len(messages)} messages using {self.chat_model}...") self.logger.log(f"Generating response to {len(messages)} messages using {self.chat_model}...")
if self.room_uses_assistant(room): if await self.room_uses_assistant(room):
return await self.generate_assistant_response(messages, room, user) return await self.generate_assistant_response(messages, room, user)
chat_partial = partial( chat_partial = partial(