faster logging

This commit is contained in:
Cyberes 2023-03-22 16:44:17 -06:00
parent 7bfc02ebbd
commit 9139edcb60
2 changed files with 14 additions and 9 deletions

View File

@ -110,7 +110,8 @@ async def main():
log_full_response=config_data['logging'].get('log_full_response', False), log_full_response=config_data['logging'].get('log_full_response', False),
system_prompt=config_data['openai'].get('system_prompt'), system_prompt=config_data['openai'].get('system_prompt'),
injected_system_prompt=config_data['openai'].get('injected_system_prompt', False), injected_system_prompt=config_data['openai'].get('injected_system_prompt', False),
openai_temperature=config_data['openai'].get('temperature', 0) openai_temperature=config_data['openai'].get('temperature', 0),
log_level=log_level
) )
client.add_event_callback(callbacks.message, RoomMessageText) client.add_event_callback(callbacks.message, RoomMessageText)
client.add_event_callback(callbacks.invite_event_filtered_callback, InviteMemberEvent) client.add_event_callback(callbacks.invite_event_filtered_callback, InviteMemberEvent)

View File

@ -28,7 +28,8 @@ class Callbacks:
system_prompt: str = None, system_prompt: str = None,
log_full_response: bool = False, log_full_response: bool = False,
injected_system_prompt: str = False, injected_system_prompt: str = False,
openai_temperature: float = 0 openai_temperature: float = 0,
log_level=logging.INFO
): ):
""" """
Args: Args:
@ -52,6 +53,7 @@ class Callbacks:
self.injected_system_prompt = injected_system_prompt self.injected_system_prompt = injected_system_prompt
self.openai_obj = openai_obj self.openai_obj = openai_obj
self.openai_temperature = openai_temperature self.openai_temperature = openai_temperature
self.log_level = log_level
async def message(self, room: MatrixRoom, event: RoomMessageText) -> None: async def message(self, room: MatrixRoom, event: RoomMessageText) -> None:
"""Callback for when a message event is received """Callback for when a message event is received
@ -150,6 +152,8 @@ class Callbacks:
) )
await command.process() await command.process()
else: else:
if self.log_level == logging.DEBUG:
# This may be a little slow
debug = { debug = {
'command_prefix': msg.startswith(f'{self.command_prefix} '), 'command_prefix': msg.startswith(f'{self.command_prefix} '),
'is_dm': room.member_count == 2, 'is_dm': room.member_count == 2,