Srinivasulu kethanaboina commited on
Commit
4200d19
·
verified ·
1 Parent(s): d76e8da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -93,7 +93,7 @@ def handle_query(query):
93
  print("Processing PDF ingestion from directory:", PDF_DIRECTORY)
94
  data_ingestion_from_directory()
95
 
96
- def predict(message, history,req):
97
  logo_html = '''
98
  <div class="circle-logo">
99
  <img src="https://rb.gy/8r06eg" alt="FernAi">
@@ -101,7 +101,7 @@ def predict(message, history,req):
101
  '''
102
  # Use the gradio_client API to process the chat history and IP address
103
  response = client.predict(
104
- ip_address=str(req), # Replace with actual IP address handling if needed
105
  chat_history=message,
106
  api_name="/predict"
107
  )
@@ -109,13 +109,10 @@ def predict(message, history,req):
109
  return response_with_logo
110
 
111
  # Define your Gradio chat interface function (replace with your actual logic)
112
- def chat_interface(message, history,request: gr.Request):
113
  try:
114
- # Generate a unique session ID for this chat session
115
- session_id = str(uuid.uuid4())
116
- req=request.client.host
117
  # Process the user message and generate a response
118
- response = predict(message, history,req)
119
 
120
  # Capture the message data
121
  message_data = {
 
93
  print("Processing PDF ingestion from directory:", PDF_DIRECTORY)
94
  data_ingestion_from_directory()
95
 
96
+ def predict(message, req):
97
  logo_html = '''
98
  <div class="circle-logo">
99
  <img src="https://rb.gy/8r06eg" alt="FernAi">
 
101
  '''
102
  # Use the gradio_client API to process the chat history and IP address
103
  response = client.predict(
104
+ ip_address=req.client.host, # Extract IP address from request
105
  chat_history=message,
106
  api_name="/predict"
107
  )
 
109
  return response_with_logo
110
 
111
  # Define your Gradio chat interface function (replace with your actual logic)
112
+ def chat_interface(message, history, request: gr.Request):
113
  try:
 
 
 
114
  # Process the user message and generate a response
115
+ response = predict(message, request)
116
 
117
  # Capture the message data
118
  message_data = {