Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,6 @@ from services.qa_service.qna import QAService
|
|
21 |
@spaces.GPU
|
22 |
def process_transcripts(files, context, session_key):
|
23 |
|
24 |
-
print(session_key)
|
25 |
with EmbeddingService(conf,
|
26 |
pinecone=pc_connector,
|
27 |
session_key=session_key) as e:
|
@@ -31,7 +30,6 @@ def process_transcripts(files, context, session_key):
|
|
31 |
@spaces.GPU
|
32 |
def retrieve_answer(question, goals, session_key):
|
33 |
|
34 |
-
print(session_key)
|
35 |
with QAService(conf,
|
36 |
pinecone=pc_connector,
|
37 |
model_pipeline=pipelines,
|
@@ -44,14 +42,21 @@ def retrieve_answer(question, goals, session_key):
|
|
44 |
|
45 |
|
46 |
def drop_namespace(arg):
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
def generate_key():
|
50 |
unique_key = str(uuid.uuid1())
|
51 |
unique_key = 'User_' + unique_key
|
52 |
-
timer = threading.Timer(
|
53 |
timer.start()
|
54 |
-
# generate new namespace in pinecone
|
55 |
|
56 |
return unique_key
|
57 |
|
|
|
21 |
@spaces.GPU
|
22 |
def process_transcripts(files, context, session_key):
|
23 |
|
|
|
24 |
with EmbeddingService(conf,
|
25 |
pinecone=pc_connector,
|
26 |
session_key=session_key) as e:
|
|
|
30 |
@spaces.GPU
|
31 |
def retrieve_answer(question, goals, session_key):
|
32 |
|
|
|
33 |
with QAService(conf,
|
34 |
pinecone=pc_connector,
|
35 |
model_pipeline=pipelines,
|
|
|
42 |
|
43 |
|
44 |
def drop_namespace(arg):
|
45 |
+
if conf["embeddings"]["override"]:
|
46 |
+
pass
|
47 |
+
print("Maintained Namespace: " + conf["embeddings"]["demo_namespace"])
|
48 |
+
else:
|
49 |
+
index = pc_connector.Index(conf["embeddings"]["index_name"])
|
50 |
+
stats=index.DescribeIndexStats()
|
51 |
+
if arg in stats['namespaces'].keys():
|
52 |
+
pc_connector.delete(namespace=arg, delete_all=True)
|
53 |
+
print("Deleted namespace: " + arg)
|
54 |
|
55 |
def generate_key():
|
56 |
unique_key = str(uuid.uuid1())
|
57 |
unique_key = 'User_' + unique_key
|
58 |
+
timer = threading.Timer(100, drop_namespace, [unique_key])
|
59 |
timer.start()
|
|
|
60 |
|
61 |
return unique_key
|
62 |
|