Ishaan Shah commited on
Commit
1a9d4cd
·
1 Parent(s): 5b417ee
Files changed (1) hide show
  1. app.py +34 -34
app.py CHANGED
@@ -103,37 +103,37 @@ def print_array(arr):
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
- # iface = gr.Interface(fn=getanswer, inputs="text", outputs="text")
113
- # iface.launch()
114
-
115
- # demo = gr.Interface(
116
- # fn=getanswer,
117
- # inputs=["text"],
118
- # outputs=["text", "text"],
119
- # api="question"
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()
 
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()