From 0d574f227a366270f05f3a106c5e667bbba88b60 Mon Sep 17 00:00:00 2001 From: raaasin Date: Sat, 23 Sep 2023 15:26:52 +0530 Subject: [PATCH] update --- app.py | 9 ++++++--- output.py | 13 ------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index 8b12e88..a520940 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ from flask import Flask, render_template, request, jsonify -from qna import question_answerer,context +from qna import pipe from judge import classifier app = Flask(__name__) @@ -20,8 +20,11 @@ def ask(): a=classifier(sequence_to_classify, candidate_labels) a=a['labels'][0] if a=='question about mining': - result = question_answerer(question=question, context=context) - answer = result['answer'] + output = pipe.run( + query=question, params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}} + ) + out=output["answers"][0].answer + answer = out chat_history.append(("Chatbot", answer)) return jsonify({"answer": answer}) else: diff --git a/output.py b/output.py index e01a8d2..0e06df2 100644 --- a/output.py +++ b/output.py @@ -1,14 +1 @@ from qna import pipe -from haystack.utils import print_answers -import io -import sys - -output_buffer = io.StringIO() -sys.stdout = output_buffer -prediction = pipe.run( - query="what is mining?", params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}} -) -print_answers(prediction, details="minimal") -sys.stdout = sys.__stdout__ -a= output_buffer.getvalue() -print(a) \ No newline at end of file