tykiww commited on
Commit
9b85101
1 Parent(s): 06c3202

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -29,26 +29,33 @@ def process_transcripts(files, context, session_key):
29
 
30
  @spaces.GPU
31
  def retrieve_answer(question, goals, session_key):
32
-
33
  with QAService(conf,
34
  pinecone=pc_connector,
35
  model_pipeline=pipelines,
36
  question=question,
37
  goals=goals,
38
- session_key=session_key) as q:
 
39
  f, c = q.run()
40
 
41
  return f, c
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
 
 
29
 
30
  @spaces.GPU
31
  def retrieve_answer(question, goals, session_key):
32
+ keycheck = namespace_check(session_key)
33
  with QAService(conf,
34
  pinecone=pc_connector,
35
  model_pipeline=pipelines,
36
  question=question,
37
  goals=goals,
38
+ session_key=session_key,
39
+ keycheck=keycheck) as q:
40
  f, c = q.run()
41
 
42
  return f, c
43
 
44
+ def namespace_check(arg):
45
+ index = pc_connector.Index(conf["embeddings"]["index_name"])
46
+ stats = index.DescribeIndexStats()
47
+ name_list = stats['namespaces'].keys()
48
+ arg in name_list
49
+ return arg in name_list
50
+
51
 
52
  def drop_namespace(arg):
53
  if conf["embeddings"]["override"]:
54
  pass
55
  print("Maintained Namespace: " + conf["embeddings"]["demo_namespace"])
56
  else:
57
+ namecheck = namespace(arg)
58
+ if namecheck:
 
59
  pc_connector.delete(namespace=arg, delete_all=True)
60
  print("Deleted namespace: " + arg)
61