Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -127,7 +127,7 @@ def update_db(user_id, conversation_id, message, response):
|
|
| 127 |
def calculate_tokens(msgs):
|
| 128 |
return sum(len(encoding.encode(str(m))) for m in msgs)
|
| 129 |
|
| 130 |
-
def limit_conversation_history(conversation: List[Dict[str, str]], max_tokens: int =
|
| 131 |
"""Limit the conversation history to a maximum number of tokens."""
|
| 132 |
limited_conversation = []
|
| 133 |
current_tokens = 0
|
|
|
|
| 127 |
def calculate_tokens(msgs):
|
| 128 |
return sum(len(encoding.encode(str(m))) for m in msgs)
|
| 129 |
|
| 130 |
+
def limit_conversation_history(conversation: List[Dict[str, str]], max_tokens: int = 7500) -> List[Dict[str, str]]:
|
| 131 |
"""Limit the conversation history to a maximum number of tokens."""
|
| 132 |
limited_conversation = []
|
| 133 |
current_tokens = 0
|