BhanuPrakashSamoju commited on
Commit
9e00170
1 Parent(s): b7a8f69

Update Index.py

Browse files
Files changed (1) hide show
  1. Index.py +19 -7
Index.py CHANGED
@@ -324,11 +324,23 @@ def rag(domain: str, question: str, evaluate: bool):
324
  # else:
325
  print("before doing Q&A")
326
  answer = _search(question, extractor)
327
- text = _prompt(question)
328
- text += "\n" + "\n".join(x["text"]for x in embeddings.search(question))
329
- print("Look here for context --> ")
330
- for i in embeddings.search(question):
331
- print("------------------------------")
332
- print(i)
 
 
 
 
 
 
 
 
 
 
 
 
333
 
334
- return {"question": question, "answer": answer}
 
324
  # else:
325
  print("before doing Q&A")
326
  answer = _search(question, extractor)
327
+ #text = _prompt(question)
328
+ #text += "\n" + "\n".join(x["text"] for x in embeddings.search(question))
329
+ context_list = sorted(embeddings.search(question), key=lambda x:x['id'])
330
+ context = "\n".join(x["text"] for x in context_list)
331
+ scored_value = ""
332
+ if evaluate:
333
+ scored_value = _create_evaluation_scenario({
334
+ "question": question,
335
+ "answer": answer,
336
+ "domain": domain,
337
+ "context": context
338
+ })
339
+ else:
340
+ scored_value = {
341
+ "input": {"question": question, "answer": answer, "domain": domain, "context": context},
342
+ "score": "Evaluation is Turned OFF"
343
+ }
344
+
345
 
346
+ return {"question": question, "answer": answer, "context": context, "score": scored_value["score"]}