Spaces:
Sleeping
Sleeping
Hammaad
commited on
Commit
•
5d17033
1
Parent(s):
beba2ee
Made change to the output paser for a question that is wrong
Browse files
reggpt/output_parsers/output_parser.py
CHANGED
@@ -20,16 +20,24 @@ def qa_chain_output_parser(result):
|
|
20 |
# "answer": result["answer"],
|
21 |
# "source_documents": result["source_documents"]
|
22 |
# }
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
def general_qa_chain_output_parser(result):
|
35 |
return {
|
@@ -48,7 +56,7 @@ def qa_agent_output_parser(query,result):
|
|
48 |
def out_of_domain_chain_parser(query):
|
49 |
return {
|
50 |
"user_input": query,
|
51 |
-
"bot_response":"
|
52 |
"format_data":[]
|
53 |
}
|
54 |
|
|
|
20 |
# "answer": result["answer"],
|
21 |
# "source_documents": result["source_documents"]
|
22 |
# }
|
23 |
+
if result["answer"] == "I currently do not have the information to answer this question. Please rephrase your question or ask another question.":
|
24 |
+
return {
|
25 |
+
"user_input": result["question"],
|
26 |
+
"bot_response": result["answer"],
|
27 |
+
"format_data": []
|
28 |
+
}
|
29 |
+
else:
|
30 |
+
|
31 |
+
metadata = [i.metadata for i in result.get("source_documents", [])]
|
32 |
+
source_documents = result.get("source_documents", [])
|
33 |
|
34 |
+
format_data = make_format(metadata, source_documents)
|
35 |
+
|
36 |
+
return {
|
37 |
+
"user_input": result["question"],
|
38 |
+
"bot_response": result["answer"],
|
39 |
+
"format_data": format_data
|
40 |
+
}
|
41 |
|
42 |
def general_qa_chain_output_parser(result):
|
43 |
return {
|
|
|
56 |
def out_of_domain_chain_parser(query):
|
57 |
return {
|
58 |
"user_input": query,
|
59 |
+
"bot_response":"sorry this question is out of my domain.",
|
60 |
"format_data":[]
|
61 |
}
|
62 |
|