feat: Add method to check if room uses assistant
This commit adds a new method `room_uses_assistant` to the OpenAI class. This method allows checking whether a given room uses an assistant. It uses the `room_settings` table in the database to determine if the specified room has the `openai_assistant` setting.
This commit is contained in:
parent
54f56c1b1a
commit
65bf724a0b
1 changed files with 16 additions and 0 deletions
|
@ -138,6 +138,22 @@ class OpenAI:
|
|||
user=user
|
||||
)
|
||||
|
||||
async def room_uses_assistant(self, room: str) -> bool:
|
||||
"""Returns whether a room uses an assistant.
|
||||
|
||||
Args:
|
||||
room (str): The room to check.
|
||||
|
||||
Returns:
|
||||
bool: Whether the room uses an assistant.
|
||||
"""
|
||||
|
||||
with closing(self.bot.database.cursor()) as cursor:
|
||||
cursor.execute("SELECT value FROM room_settings WHERE room_id = ? AND setting = ?", (room, "openai_assistant"))
|
||||
result = cursor.fetchone()
|
||||
|
||||
return result is not None
|
||||
|
||||
async def generate_chat_response(self, messages: List[Dict[str, str]], user: Optional[str] = None, room: Optional[str] = None) -> Tuple[str, int]:
|
||||
"""Generate a response to a chat message.
|
||||
|
||||
|
|
Loading…
Reference in a new issue