vSiddi
commited on
Commit
·
0e70f2c
1
Parent(s):
808ced4
fix issue
Browse files- modules/common_utils.py +4 -4
modules/common_utils.py
CHANGED
@@ -61,8 +61,7 @@ def construct_messages_to_send(page, message_store, prompt):
|
|
61 |
system_message_content = message_store.get_message(page, "system")
|
62 |
greeting_message_content = message_store.get_message(page, "greeting")
|
63 |
if system_message_content:
|
64 |
-
|
65 |
-
messages_to_send.append({"role": "system", "content": system_message_content })
|
66 |
if greeting_message_content:
|
67 |
messages_to_send.append({"role": "assistant", "content": greeting_message_content})
|
68 |
|
@@ -70,20 +69,21 @@ def construct_messages_to_send(page, message_store, prompt):
|
|
70 |
history_messages = message_store.get_history(page)
|
71 |
|
72 |
# Check if there are enough messages in the history, if not, adjust the slicing
|
73 |
-
num_messages_to_include =
|
74 |
if len(history_messages) < num_messages_to_include:
|
75 |
num_messages_to_include = len(history_messages)
|
76 |
|
77 |
recent_history = history_messages[-num_messages_to_include:]
|
78 |
for msg in recent_history:
|
79 |
messages_to_send.append({"role": msg["role"], "content": msg["content"]})
|
80 |
-
|
81 |
# Append the current user prompt
|
82 |
messages_to_send.append({"role": "user", "content": prompt})
|
83 |
|
84 |
return messages_to_send
|
85 |
|
86 |
|
|
|
87 |
def get_content_mapping_to_module(content_type):
|
88 |
content_type_lower = content_type.lower()
|
89 |
# Iterate through each page in PAGE_CONFIG
|
|
|
61 |
system_message_content = message_store.get_message(page, "system")
|
62 |
greeting_message_content = message_store.get_message(page, "greeting")
|
63 |
if system_message_content:
|
64 |
+
messages_to_send.append({"role": "system", "content": system_message_content})
|
|
|
65 |
if greeting_message_content:
|
66 |
messages_to_send.append({"role": "assistant", "content": greeting_message_content})
|
67 |
|
|
|
69 |
history_messages = message_store.get_history(page)
|
70 |
|
71 |
# Check if there are enough messages in the history, if not, adjust the slicing
|
72 |
+
num_messages_to_include = 10 # Include last two pairs (user and assistant)
|
73 |
if len(history_messages) < num_messages_to_include:
|
74 |
num_messages_to_include = len(history_messages)
|
75 |
|
76 |
recent_history = history_messages[-num_messages_to_include:]
|
77 |
for msg in recent_history:
|
78 |
messages_to_send.append({"role": msg["role"], "content": msg["content"]})
|
79 |
+
|
80 |
# Append the current user prompt
|
81 |
messages_to_send.append({"role": "user", "content": prompt})
|
82 |
|
83 |
return messages_to_send
|
84 |
|
85 |
|
86 |
+
|
87 |
def get_content_mapping_to_module(content_type):
|
88 |
content_type_lower = content_type.lower()
|
89 |
# Iterate through each page in PAGE_CONFIG
|