Load, Save Conversation Session Summaries to Log. s/chat_log/chat_session

Conversation logs structure now has session info too instead of just chat info
Session info will allow loading past conversation summaries as context for AI in new conversations

{
    "session": [
    {
        "summary": <chat_session_summary>,
        "session-start": <session_start_index_in_chat_log>,
        "session-end": <session_end_index_in_chat_log>
    }],
    "chat": [
    {
        "intent": <intent-object>
        "trigger-emotion": <emotion-triggered-by-message>
        "by": <AI|Human>
        "message": <chat_message>
        "created": <message_created_date>
    }]
}
This commit is contained in:
Debanjum Singh Solanky
2021-12-08 02:34:52 +05:30
parent 0ac1e5f372
commit 65da7daf1f
3 changed files with 28 additions and 19 deletions

View File

@@ -113,3 +113,8 @@ def message_to_log(user_message, user_message_metadata, gpt_message, conversatio
conversation_log.extend([human_log, ai_log])
return conversation_log
def extract_summaries(metadata):
"""Extract summaries from metadata"""
return ''.join(
[f'\n{session["summary"]}' for session in metadata])