Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,15 @@ import uuid
|
|
13 |
|
14 |
logger.info(100*"#")
|
15 |
logger.info("Initializing gradio!")
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
18 |
import os
|
19 |
import requests
|
@@ -44,7 +52,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
44 |
ret=response.json()
|
45 |
return ret['result']
|
46 |
|
47 |
-
def respond(message, chat_history):
|
|
|
48 |
bot_message=call_api(message,12,"xyz")
|
49 |
chat_history.append((message, bot_message))
|
50 |
return "", chat_history
|
@@ -52,7 +61,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
52 |
chatbot = gr.Chatbot(label='Jivi')
|
53 |
msg = gr.Textbox(label='Patient')
|
54 |
clear = gr.ClearButton([msg, chatbot])
|
55 |
-
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
56 |
|
57 |
|
58 |
demo.launch(auth=(os.environ.get("USER","demo"), os.environ.get("PASSWORD","demo")))
|
|
|
13 |
|
14 |
logger.info(100*"#")
|
15 |
logger.info("Initializing gradio!")
|
16 |
+
|
17 |
+
get_window_url_params = """
|
18 |
+
function(text_input, url_params) {
|
19 |
+
console.log(text_input, url_params);
|
20 |
+
const params = new URLSearchParams(window.location.search);
|
21 |
+
url_params = Object.fromEntries(params);
|
22 |
+
return [text_input, url_params];
|
23 |
+
}
|
24 |
+
"""
|
25 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
26 |
import os
|
27 |
import requests
|
|
|
52 |
ret=response.json()
|
53 |
return ret['result']
|
54 |
|
55 |
+
def respond(message, chat_history,url_params):
|
56 |
+
print("params",url_params)
|
57 |
bot_message=call_api(message,12,"xyz")
|
58 |
chat_history.append((message, bot_message))
|
59 |
return "", chat_history
|
|
|
61 |
chatbot = gr.Chatbot(label='Jivi')
|
62 |
msg = gr.Textbox(label='Patient')
|
63 |
clear = gr.ClearButton([msg, chatbot])
|
64 |
+
msg.submit(respond, [msg, chatbot,url_params], [msg, chatbot],_js=get_window_url_params)
|
65 |
|
66 |
|
67 |
demo.launch(auth=(os.environ.get("USER","demo"), os.environ.get("PASSWORD","demo")))
|