fix logging

This commit is contained in:
Cyberes 2023-03-18 15:04:12 -06:00
parent f5ad27d434
commit 31d8e415ea
3 changed files with 21 additions and 21 deletions

View File

@ -39,7 +39,7 @@ reply_in_thread: true
# For example, you can instruct the assistant with "You are a helpful assistant."
#system_prompt:
# Log the full response (prompt + response).
# Log the full response (prompt + response) at debug level.
log_full_response: false
logout_other_devices: false

View File

@ -198,7 +198,6 @@ async def process_chat(client, room, event, command, store, openai, thread_root_
]
if system_prompt:
messages.insert(0, {"role": "system", "content": system_prompt}, )
print(messages)
response = openai['openai'].ChatCompletion.create(
model=openai['model'],
@ -206,15 +205,16 @@ async def process_chat(client, room, event, command, store, openai, thread_root_
temperature=0,
)
text_response = response["choices"][0]["message"]["content"].strip().strip('\n')
z = text_response.replace("\n", "\\n")
if log_full_response:
logger.debug({'event_id': event.event_id, 'room': room.room_id, 'messages': messages, 'response': text_response})
z = text_response.replace("\n", "\\n")
if isinstance(command, str):
x = command.replace("\n", "\\n")
else:
x = command
logger.info(f'Reply to {event.event_id} --> "{x}" and bot responded with "{z}"')
else:
logger.info(f'Reply to {event.event_id} --> "{z}"')
resp = await send_text_to_room(client, room.room_id, text_response, reply_to_event_id=event.event_id, thread=True, thread_root_id=thread_root_id if thread_root_id else event.event_id)
await client.room_typing(room.room_id, typing_state=False, timeout=3000)
store.add_event_id(event.event_id)