Spaces:
Runtime error
Runtime error
Commit
·
d588c5a
1
Parent(s):
3dea0e3
Update app.py
Browse files
app.py
CHANGED
@@ -17,12 +17,15 @@ chain = load_qa_chain(OpenAI(openai_api_key=os.environ['OPENAI_API_KEY']), chain
|
|
17 |
|
18 |
def learn_from_chanakya_neeti(chat_history,query):
|
19 |
docs = docsearch.similarity_search(query)
|
20 |
-
result = chain.run(input_documents=docs, question=query)
|
|
|
21 |
return chat_history + [(query,result)]
|
22 |
|
23 |
with gr.Blocks() as demo:
|
|
|
|
|
24 |
chatbot = gr.Chatbot()
|
25 |
-
textbox = gr.Textbox(label="
|
26 |
|
27 |
textbox.submit(fn=learn_from_chanakya_neeti,inputs=[chatbot,textbox],outputs=[chatbot])
|
28 |
|
|
|
17 |
|
18 |
def learn_from_chanakya_neeti(chat_history,query):
|
19 |
docs = docsearch.similarity_search(query)
|
20 |
+
result = result if (result:=chain.run(input_documents=docs, question=query)) != "I don’t know." else "Please only ask questions from chanakya neeti."
|
21 |
+
|
22 |
return chat_history + [(query,result)]
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
+
gr.HTML(value="""<h1 style="text-align: center;">Chankya Neeti</h1>""")
|
26 |
+
gr.Markdown("Chanakya Neeti is the essence of various scriptures Chanakya carefully studied to come up with a code of conduct that will benefit all mankind. It is a book written by Chanakya, a great scholar, to simplify complicated scriptures and provide a practical application of moral codes and ideal conduct.")
|
27 |
chatbot = gr.Chatbot()
|
28 |
+
textbox = gr.Textbox(label="Ask your question.",placeholder="How can one build a strong and successful team?")
|
29 |
|
30 |
textbox.submit(fn=learn_from_chanakya_neeti,inputs=[chatbot,textbox],outputs=[chatbot])
|
31 |
|