bumk766fall2023 commited on
Commit
7ab78c1
·
1 Parent(s): dd4984c

Fixes for major version

Browse files
Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -44,27 +44,33 @@ with gr.Blocks(theme = theme) as demo:
44
 
45
  DelayBetweenWords_state = gr.State(0.0001)
46
  DelayBetweenLetters_state = gr.State(0.0001)
 
47
  url_params = gr.State()
48
 
49
 
50
  def get_params(request: gr.Request):
51
  global global_params
52
- print("INSIDE GET PARAM FUNCTION")
53
  headers = request.headers
54
  host = request.client.host
55
  user_agent = request.headers["user-agent"]
56
  params = request.query_params
57
 
58
  global_params = str(params)
59
-
60
- return {
61
- "ip": host,
62
- "user_agent": user_agent,
63
- "headers": headers,
64
- "URL_params": params,
65
- }
 
 
 
 
66
 
67
  #j = gr.JSON(render=False)
 
68
  demo.load(get_params, None, url_params, queue=False)
69
  #demo.load(get_params, None, j)
70
  #print("IN gr.Blocks")
@@ -77,7 +83,7 @@ with gr.Blocks(theme = theme) as demo:
77
  def user(user_message, history):
78
  return "", history + [[user_message, None]]
79
 
80
- def bot(history):
81
 
82
  #time.sleep(.02)
83
  #bot_message = chat(user_message)
@@ -96,12 +102,15 @@ with gr.Blocks(theme = theme) as demo:
96
  #print("AFTER PRINT url_params")
97
  #query_string = url_params
98
 
 
 
 
99
  DelayBetweenWords = 0.1
100
  DelayBetweenLetters = 0.1
101
  params = ""
102
 
103
- if global_params != "":
104
- params = parse_query_params(global_params)
105
  DelayBetweenWords = int(params.get("dw"))/1000
106
  DelayBetweenLetters = int(params.get("dl"))/1000
107
 
@@ -119,6 +128,9 @@ with gr.Blocks(theme = theme) as demo:
119
  #print("KEYWORD FOUND")
120
  #print(search_keyword)
121
 
 
 
 
122
  if search_keyword != "None":
123
  bot_message = qs['a']
124
  else:
 
44
 
45
  DelayBetweenWords_state = gr.State(0.0001)
46
  DelayBetweenLetters_state = gr.State(0.0001)
47
+
48
  url_params = gr.State()
49
 
50
 
51
  def get_params(request: gr.Request):
52
  global global_params
53
+
54
  headers = request.headers
55
  host = request.client.host
56
  user_agent = request.headers["user-agent"]
57
  params = request.query_params
58
 
59
  global_params = str(params)
60
+ state_out = global_params
61
+
62
+ print("GET PARAM CALL: "+ state_out)
63
+
64
+ return state_out
65
+ #return {
66
+ # "ip": host,
67
+ # "user_agent": user_agent,
68
+ # "headers": headers,
69
+ # "URL_params": params,
70
+ #}
71
 
72
  #j = gr.JSON(render=False)
73
+ #demo.load(get_params, None, url_params, queue=False)
74
  demo.load(get_params, None, url_params, queue=False)
75
  #demo.load(get_params, None, j)
76
  #print("IN gr.Blocks")
 
83
  def user(user_message, history):
84
  return "", history + [[user_message, None]]
85
 
86
+ def bot(request: gr.Request, history):
87
 
88
  #time.sleep(.02)
89
  #bot_message = chat(user_message)
 
102
  #print("AFTER PRINT url_params")
103
  #query_string = url_params
104
 
105
+ request_params = str(request.query_params)
106
+ #print("REQUEST IN BOT " + str(params))
107
+
108
  DelayBetweenWords = 0.1
109
  DelayBetweenLetters = 0.1
110
  params = ""
111
 
112
+ if request_params != "":
113
+ params = parse_query_params(request_params)
114
  DelayBetweenWords = int(params.get("dw"))/1000
115
  DelayBetweenLetters = int(params.get("dl"))/1000
116
 
 
128
  #print("KEYWORD FOUND")
129
  #print(search_keyword)
130
 
131
+ print("GET PARAM CALL: "+ str(url_params))
132
+
133
+
134
  if search_keyword != "None":
135
  bot_message = qs['a']
136
  else: