Reality123b commited on
Commit
52fe3c7
·
verified ·
1 Parent(s): 9b71c73

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +38 -24
config.py CHANGED
@@ -1,24 +1,38 @@
1
- from flask import Flask,request,render_template,request,Response,jsonify
2
- from application.utils.convs_handler import ConvHandler
3
- import json
4
-
5
- pipeline_path = './pipeline.json'
6
-
7
- with open(pipeline_path, 'r') as file:
8
- pipeline_dict = json.load(file)
9
-
10
- convs_dict = {
11
- #format---> ip:{
12
- # convId:{
13
- # messages = [],
14
- # }
15
- # ...
16
- # metadata (a list containing all convId and title in dict format) = [
17
- # {
18
- # "convID",
19
- # "convTitle"
20
- # }...]
21
- #
22
- }
23
-
24
- convHandler = ConvHandler(convs_dict=convs_dict)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)