Spaces:
Running
Running
Update config.py
Browse files
config.py
CHANGED
|
@@ -1,24 +1,38 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
-
#
|
| 16 |
-
#
|
| 17 |
-
#
|
| 18 |
-
#
|
| 19 |
-
#
|
| 20 |
-
#
|
| 21 |
-
#
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# config.py
|
| 2 |
+
from flask import Flask, request, render_template, request, Response, jsonify
|
| 3 |
+
from application.utils.convs_handler import ConvHandler
|
| 4 |
+
import json
|
| 5 |
+
import uuid # Import uuid
|
| 6 |
+
|
| 7 |
+
pipeline_path = './pipeline.json'
|
| 8 |
+
|
| 9 |
+
with open(pipeline_path, 'r') as file:
|
| 10 |
+
pipeline_dict = json.load(file)
|
| 11 |
+
|
| 12 |
+
convs_dict = {
|
| 13 |
+
# format---> ip:{
|
| 14 |
+
# convId:{
|
| 15 |
+
# messages = [],
|
| 16 |
+
# }
|
| 17 |
+
# ...
|
| 18 |
+
# metadata (a list containing all convId and title in dict format) = [
|
| 19 |
+
# {
|
| 20 |
+
# "convID",
|
| 21 |
+
# "convTitle"
|
| 22 |
+
# }...]
|
| 23 |
+
#
|
| 24 |
+
# memory: "" # Add memory field here
|
| 25 |
+
# }
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def get_user_id():
|
| 30 |
+
user_id = request.cookies.get('user_id')
|
| 31 |
+
if not user_id:
|
| 32 |
+
user_id = str(uuid.uuid4())
|
| 33 |
+
if user_id not in convs_dict:
|
| 34 |
+
convs_dict[user_id] = {"metadata": [], "memory": ""} # Initialize memory
|
| 35 |
+
return user_id
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
convHandler = ConvHandler(convs_dict=convs_dict)
|