tykiww commited on
Commit
06c3202
1 Parent(s): 96dfd33

Update services/qa_service/qna.py

Browse files
Files changed (1) hide show
  1. services/qa_service/qna.py +12 -7
services/qa_service/qna.py CHANGED
@@ -5,14 +5,17 @@ from services.qa_service.utils import format_prompt
5
 
6
 
7
  class QAService:
8
- def __init__(self, conf, pinecone, model_pipeline, question, goals, session_key):
9
  self.conf = conf
10
- self.pinecones = pinecone.run(namespace=conf["embeddings"]["demo_namespace"])
11
- if session_key != "":
12
- self.pinecones = pinecone.run(namespace=session_key) # need some security to determine whether it was one of the keys generated.
 
 
 
 
13
 
14
  self.pc = self.pinecones['connection']
15
- self.pc_index = self.pc.Index(self.conf['embeddings']['index_name'])
16
  self.embedder = self.pinecones['embedder']
17
  self.model_pipeline = model_pipeline
18
  self.question = question
@@ -42,9 +45,11 @@ class QAService:
42
  """Pass embedded question into pinecone"""
43
  embedded_query = self.embedder.get_text_embedding(self.question)
44
 
45
- result = self.pc_index.query(
 
46
  vector=embedded_query,
47
- top_k=5, # I think namespace comes somewhere here during querying!!! No need for pipeline (:
 
48
  include_values=False,
49
  include_metadata=True
50
  )
 
5
 
6
 
7
  class QAService:
8
+ def __init__(self, conf, pinecone, model_pipeline, question, goals, session_key, keycheck):
9
  self.conf = conf
10
+
11
+ if keycheck:
12
+ self.sess_key = session_key
13
+ self.pinecones = pinecone.run(namespace=self.sess_key)
14
+ else:
15
+ self.sess_key = self.conf["embeddings"]["demo_namespace"]
16
+ self.pinecones = pinecone.run(namespace=self.sess_key)
17
 
18
  self.pc = self.pinecones['connection']
 
19
  self.embedder = self.pinecones['embedder']
20
  self.model_pipeline = model_pipeline
21
  self.question = question
 
45
  """Pass embedded question into pinecone"""
46
  embedded_query = self.embedder.get_text_embedding(self.question)
47
 
48
+ index = self.pc.Index(self.conf['embeddings']['index_name'])
49
+ result = index.query(
50
  vector=embedded_query,
51
+ namespace=self.sess_key, # I think namespace comes somewhere here during querying!!!
52
+ top_k=5,
53
  include_values=False,
54
  include_metadata=True
55
  )