Spaces:
Runtime error
Runtime error
Commit
·
9e00170
1
Parent(s):
b7a8f69
Update Index.py
Browse files
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 |
-
|
330 |
-
for
|
331 |
-
|
332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"]}
|