Ishaan Shah
commited on
Commit
·
1a9d4cd
1
Parent(s):
5b417ee
api
Browse files
app.py
CHANGED
@@ -103,37 +103,37 @@ def print_array(arr):
|
|
103 |
arr_str = str(arr)
|
104 |
return arr_str
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
with gr.Blocks() as demo:
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
demo.launch()
|
|
|
103 |
arr_str = str(arr)
|
104 |
return arr_str
|
105 |
|
106 |
+
def getanswer(question):
|
107 |
+
llm_response = qa_chain(question)
|
108 |
+
response = process_llm_response(llm_response)
|
109 |
+
sources= print_array(response["sources"])
|
110 |
+
return response["result"], sources
|
111 |
+
|
112 |
+
|
113 |
+
demo = gr.Interface(
|
114 |
+
fn=getanswer,
|
115 |
+
inputs=["text"],
|
116 |
+
outputs=["text", "text"],
|
117 |
+
api="question",
|
118 |
+
title="Medihelp Chatbot",
|
119 |
+
|
120 |
+
)
|
121 |
+
demo.launch()
|
122 |
+
|
123 |
+
# with gr.Blocks() as demo:
|
124 |
+
# chatbot = gr.Chatbot()
|
125 |
+
# msg = gr.Textbox()
|
126 |
+
# clear = gr.Button("Clear")
|
127 |
+
|
128 |
+
# def getanswer(question, chat_history):
|
129 |
+
# llm_response = qa_chain(question)
|
130 |
+
# response = process_llm_response(llm_response)
|
131 |
+
# sources= print_array(response["sources"])
|
132 |
+
# processed_response = response["result"] +" \n\nSources: " + sources
|
133 |
+
# chat_history.append((question, processed_response))
|
134 |
+
# return "", chat_history
|
135 |
+
|
136 |
+
# msg.submit(getanswer, [msg, chatbot], [msg, chatbot])
|
137 |
+
# clear.click(lambda: None, None, chatbot, queue=False)
|
138 |
+
|
139 |
+
# demo.launch()
|