Michael S. Trusov commited on
Commit
98f345d
·
1 Parent(s): 510a6aa

November 3 commit to Hugging Face

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -22,6 +22,13 @@ theme = gr.themes.Base(
22
  )
23
 
24
 
 
 
 
 
 
 
 
25
  import uuid
26
 
27
  # Add a function to generate a unique session ID
@@ -137,8 +144,17 @@ with gr.Blocks(theme = theme) as demo:
137
  url_params = gr.State()
138
  session_id = gr.State()
139
 
 
 
 
140
  #demo.load(get_params, None, url_params, queue=False)
141
  demo.load(get_params, None, [url_params, session_id], queue=False)
 
 
 
 
 
 
142
 
143
  #demo.load(get_params, param_hiddentextbox, param_hiddentextbox, queue=False)
144
 
@@ -268,7 +284,7 @@ with gr.Blocks(theme = theme) as demo:
268
  yield history
269
 
270
  log_message("-EXIT - [query]: " + text + " [params]: " + url_params + " [keyword]: " + search_keyword, session_id)
271
- return history
272
  # --------------------------------------------------------------------------------------------
273
 
274
 
 
22
  )
23
 
24
 
25
+ # Define the function to handle API calls for the chatbot response
26
+ def chatbot_api(user_message):
27
+ # Process the input and generate a response
28
+ response = f"Chatbot response to: {user_message}" # Example response generation
29
+ return response
30
+
31
+
32
  import uuid
33
 
34
  # Add a function to generate a unique session ID
 
144
  url_params = gr.State()
145
  session_id = gr.State()
146
 
147
+
148
+
149
+
150
  #demo.load(get_params, None, url_params, queue=False)
151
  demo.load(get_params, None, [url_params, session_id], queue=False)
152
+
153
+ # Add invisible API endpoint using these components
154
+ invisible_input = gr.Textbox(visible=False)
155
+ invisible_output = gr.Textbox(visible=False)
156
+ demo.load(chatbot_api, inputs=invisible_input, outputs=invisible_output, api_name="chatbot_endpoint")
157
+
158
 
159
  #demo.load(get_params, param_hiddentextbox, param_hiddentextbox, queue=False)
160
 
 
284
  yield history
285
 
286
  log_message("-EXIT - [query]: " + text + " [params]: " + url_params + " [keyword]: " + search_keyword, session_id)
287
+
288
  # --------------------------------------------------------------------------------------------
289
 
290