botsi commited on
Commit
d9f139d
·
verified ·
1 Parent(s): affcab3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -2,13 +2,6 @@ import gradio as gr
2
  import time
3
  import random
4
  import json
5
-
6
- # To test open trust-game-llama2-7b in terminal,
7
- # open conda environment via conda activate
8
- # and run this file via python3 data_fetcher.py
9
-
10
- # Example from here: https://www.techgropse.com/blog/how-to-return-sql-data-in-json-format-python/
11
- # Use the built-in json module and the pymysql package if using MySQL as database:
12
  import mysql.connector
13
  import json
14
  import requests
@@ -67,12 +60,13 @@ get_window_url_params = """
67
  """
68
 
69
  with gr.Blocks() as demo:
70
- gr.Markdown("""##Please insert`read query`in order to get the URL Parameters from the chatbot""")
 
 
71
  url_params = gr.JSON({}, visible=False, label="URL Params")
72
  chatbot = gr.Chatbot().style(height=500)
73
  msg = gr.Textbox()
74
  clear = gr.Button("Clear")
75
- json_result = fetch_data_as_json()
76
 
77
  def user(user_message, url_params, history):
78
  return "", history + [[user_message, None]]
@@ -84,7 +78,7 @@ with gr.Blocks() as demo:
84
  {json.dumps(url_params, indent=4)}
85
  """
86
  else:
87
- bot_message = random.choice(["Yes", "No"])
88
  history[-1][1] = bot_message
89
  time.sleep(1)
90
  return history
 
2
  import time
3
  import random
4
  import json
 
 
 
 
 
 
 
5
  import mysql.connector
6
  import json
7
  import requests
 
60
  """
61
 
62
  with gr.Blocks() as demo:
63
+ gr.Markdown("""## Gradio send queryparam to chatbot
64
+ type `read query`
65
+ """)
66
  url_params = gr.JSON({}, visible=False, label="URL Params")
67
  chatbot = gr.Chatbot().style(height=500)
68
  msg = gr.Textbox()
69
  clear = gr.Button("Clear")
 
70
 
71
  def user(user_message, url_params, history):
72
  return "", history + [[user_message, None]]
 
78
  {json.dumps(url_params, indent=4)}
79
  """
80
  else:
81
+ bot_message = random.choice(["Yes", "No"])
82
  history[-1][1] = bot_message
83
  time.sleep(1)
84
  return history