Spaces:
Sleeping
Sleeping
vkrishnan569
commited on
Commit
•
4374687
1
Parent(s):
2e1942c
Update main.py
Browse files
main.py
CHANGED
@@ -126,7 +126,7 @@ system_prompt = (
|
|
126 |
conversation_history = [{"role": "system", "content": system_prompt}]
|
127 |
|
128 |
# Define conversation history size limit
|
129 |
-
MAX_CONVERSATION_HISTORY_SIZE =
|
130 |
|
131 |
# Create a Flask application
|
132 |
app = Flask(__name__)
|
@@ -145,7 +145,7 @@ def calculate_total_tokens(messages):
|
|
145 |
def trim_conversation_history():
|
146 |
global conversation_history
|
147 |
total_tokens = calculate_total_tokens(conversation_history)
|
148 |
-
context_window_size =
|
149 |
|
150 |
while total_tokens > context_window_size:
|
151 |
# Remove the oldest messages from the conversation history
|
|
|
126 |
conversation_history = [{"role": "system", "content": system_prompt}]
|
127 |
|
128 |
# Define conversation history size limit
|
129 |
+
MAX_CONVERSATION_HISTORY_SIZE = 2000
|
130 |
|
131 |
# Create a Flask application
|
132 |
app = Flask(__name__)
|
|
|
145 |
def trim_conversation_history():
|
146 |
global conversation_history
|
147 |
total_tokens = calculate_total_tokens(conversation_history)
|
148 |
+
context_window_size = 2000
|
149 |
|
150 |
while total_tokens > context_window_size:
|
151 |
# Remove the oldest messages from the conversation history
|