Spaces:
Sleeping
Sleeping
Update services/qa_service/qna.py
Browse files- 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 |
-
|
11 |
-
if
|
12 |
-
self.
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
46 |
vector=embedded_query,
|
47 |
-
|
|
|
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 |
)
|