Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
raaasin committed Sep 23, 2023
1 parent 582001f commit 0d574f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
9 changes: 6 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand All @@ -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:
Expand Down
13 changes: 0 additions & 13 deletions output.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 0d574f2

Please sign in to comment.