Spaces:
Runtime error
Runtime error
jay-maharlika
commited on
Commit
•
3df47d4
1
Parent(s):
2d413d8
Update app.py
Browse files
app.py
CHANGED
@@ -39,14 +39,11 @@ def get_response_from_query(db, query, k=3):
|
|
39 |
prompt = PromptTemplate(
|
40 |
input_variables=["question", "docs"],
|
41 |
template="""
|
42 |
-
|
43 |
Answer the following question: {question}
|
44 |
By searching the following articles: {docs}
|
45 |
-
|
46 |
Only use the factual information from the documents. Make sure to mention key phrases from the articles.
|
47 |
-
|
48 |
If you feel like you don't have enough information to answer the question, say "I don't know".
|
49 |
-
|
50 |
""",
|
51 |
)
|
52 |
|
@@ -60,10 +57,8 @@ def get_response_from_query(db, query, k=3):
|
|
60 |
input_variables=["answer", "docs"],
|
61 |
template="""
|
62 |
You job is to evaluate if the response to a given context is faithful.
|
63 |
-
|
64 |
for the following: {answer}
|
65 |
By searching the following article: {docs}
|
66 |
-
|
67 |
Give a reason why they are similar or not, start with a Yes or a No.
|
68 |
""",
|
69 |
)
|
@@ -82,14 +77,14 @@ def greet(query):
|
|
82 |
answer,sources,evals = get_response_from_query(db,query,2)
|
83 |
return answer,sources,evals
|
84 |
examples = [
|
85 |
-
["How to
|
86 |
-
["
|
87 |
-
["
|
88 |
-
["
|
89 |
-
["
|
90 |
-
["
|
91 |
]
|
92 |
-
demo = gr.Interface(fn=greet, title="
|
93 |
outputs=[gr.components.Textbox(lines=3, label="Response"),
|
94 |
gr.components.Textbox(lines=3, label="Source"),
|
95 |
gr.components.Textbox(lines=3, label="Evaluation")],
|
|
|
39 |
prompt = PromptTemplate(
|
40 |
input_variables=["question", "docs"],
|
41 |
template="""
|
42 |
+
A bot that is open to discussions about different cultural, philosophical and political exchanges. I will use do different analysis to the articles provided to me. Stay truthful and if you weren't provided any resources give your oppinion only.
|
43 |
Answer the following question: {question}
|
44 |
By searching the following articles: {docs}
|
|
|
45 |
Only use the factual information from the documents. Make sure to mention key phrases from the articles.
|
|
|
46 |
If you feel like you don't have enough information to answer the question, say "I don't know".
|
|
|
47 |
""",
|
48 |
)
|
49 |
|
|
|
57 |
input_variables=["answer", "docs"],
|
58 |
template="""
|
59 |
You job is to evaluate if the response to a given context is faithful.
|
|
|
60 |
for the following: {answer}
|
61 |
By searching the following article: {docs}
|
|
|
62 |
Give a reason why they are similar or not, start with a Yes or a No.
|
63 |
""",
|
64 |
)
|
|
|
77 |
answer,sources,evals = get_response_from_query(db,query,2)
|
78 |
return answer,sources,evals
|
79 |
examples = [
|
80 |
+
["How to be happy"],
|
81 |
+
["Climate Change Challenges in Europe"],
|
82 |
+
["Philosophy in the world of Minimalism"],
|
83 |
+
["Hate Speech vs Freedom of Speech"],
|
84 |
+
["Articles by Noam Chomsky on US Politics"],
|
85 |
+
["The importance of values and reflection"]
|
86 |
]
|
87 |
+
demo = gr.Interface(fn=greet, title="cicero-semantic-search", inputs="text",
|
88 |
outputs=[gr.components.Textbox(lines=3, label="Response"),
|
89 |
gr.components.Textbox(lines=3, label="Source"),
|
90 |
gr.components.Textbox(lines=3, label="Evaluation")],
|