Srinivasulu kethanaboina commited on
Commit
f40383a
1 Parent(s): ca16a7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -21
app.py CHANGED
@@ -7,8 +7,6 @@ from llama_index.embeddings.huggingface import HuggingFaceEmbedding
7
  import datetime
8
  import uuid
9
  import random
10
- import flask
11
- from flask import request, redirect, make_response
12
 
13
  def select_random_name():
14
  names = ['Clara', 'Lily']
@@ -104,24 +102,13 @@ def predict(message, history):
104
 
105
  def chat_interface(message, history):
106
  try:
107
- # Generate a unique session ID for this chat session
108
- session_id = str(uuid.uuid4())
109
-
110
- # Process the user message and generate a response (your chatbot logic)
111
  response = handle_query(message)
112
 
113
- # Capture the message data
114
- message_data = {
115
- "sender": "user",
116
- "message": message,
117
- "response": response,
118
- "timestamp": datetime.datetime.now().isoformat() # Use a library like datetime
119
- }
120
-
121
- # Store chat history in cookies (for demo purposes)
122
- resp = make_response(response)
123
- resp.set_cookie('chat_history', str(current_chat_history))
124
- return resp
125
  except Exception as e:
126
  return str(e)
127
 
@@ -161,8 +148,16 @@ label.svelte-1b6s6s {display: none}
161
  div.svelte-rk35yg {display: none;}
162
  div.progress-text.svelte-z7cif2.meta-text {display: none;}
163
  '''
164
- def redirect_page():
165
- return redirect("https://example.com") # Replace with your target URL
 
 
 
 
 
 
 
 
166
 
167
  gr.Interface(
168
  fn=chat_interface,
@@ -170,5 +165,5 @@ gr.Interface(
170
  outputs="html",
171
  live=True,
172
  css=css,
173
- description="<button onclick='window.location.href=\"https://example.com\"'>Redirect to another page</button>"
174
  ).launch()
 
7
  import datetime
8
  import uuid
9
  import random
 
 
10
 
11
  def select_random_name():
12
  names = ['Clara', 'Lily']
 
102
 
103
  def chat_interface(message, history):
104
  try:
105
+ # Process the user message and generate a response
 
 
 
106
  response = handle_query(message)
107
 
108
+ # Update chat history
109
+ current_chat_history.append((message, response))
110
+
111
+ return response
 
 
 
 
 
 
 
 
112
  except Exception as e:
113
  return str(e)
114
 
 
148
  div.svelte-rk35yg {display: none;}
149
  div.progress-text.svelte-z7cif2.meta-text {display: none;}
150
  '''
151
+
152
+ # Define JavaScript for redirection
153
+ js = '''
154
+ <script>
155
+ function redirectToPage() {
156
+ window.location.href = "https://example.com"; // Replace with your target URL
157
+ }
158
+ </script>
159
+ <button onclick="redirectToPage()">Redirect to another page</button>
160
+ '''
161
 
162
  gr.Interface(
163
  fn=chat_interface,
 
165
  outputs="html",
166
  live=True,
167
  css=css,
168
+ description=js
169
  ).launch()