Lasdw commited on
Commit
eabd88b
·
1 Parent(s): 7407a06

updated rate limting for ips 4

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -47,7 +47,8 @@ def chat_with_agent(question: str, file_uploads, history: list) -> tuple:
47
  f"Rate limit exceeded. You can make {query_limiter.max_queries} queries per hour. Think of my bank account🙏. "
48
  f"Please wait {int(remaining_time)} seconds before trying again."
49
  )
50
- history.append((question, error_message))
 
51
  return history, "", f"Remaining queries this hour: 0/{query_limiter.max_queries}"
52
 
53
  # Initialize agent
@@ -115,13 +116,15 @@ def chat_with_agent(question: str, file_uploads, history: list) -> tuple:
115
  # Add remaining queries info
116
  remaining_queries = query_limiter.get_remaining_queries(ip_address)
117
 
118
- # Add question and response to history in the correct format (as tuples)
119
- history.append((question, formatted_response))
 
120
 
121
  return history, "", f"Remaining queries this hour: {remaining_queries}/{query_limiter.max_queries}"
122
  except Exception as e:
123
  error_message = f"Error: {str(e)}"
124
- history.append((question, error_message))
 
125
  return history, "", "Remaining queries this hour: 5/5"
126
 
127
  def clear_chat():
 
47
  f"Rate limit exceeded. You can make {query_limiter.max_queries} queries per hour. Think of my bank account🙏. "
48
  f"Please wait {int(remaining_time)} seconds before trying again."
49
  )
50
+ history.append({"role": "user", "content": question})
51
+ history.append({"role": "assistant", "content": error_message})
52
  return history, "", f"Remaining queries this hour: 0/{query_limiter.max_queries}"
53
 
54
  # Initialize agent
 
116
  # Add remaining queries info
117
  remaining_queries = query_limiter.get_remaining_queries(ip_address)
118
 
119
+ # Add question and response to history in the correct format
120
+ history.append({"role": "user", "content": question})
121
+ history.append({"role": "assistant", "content": formatted_response})
122
 
123
  return history, "", f"Remaining queries this hour: {remaining_queries}/{query_limiter.max_queries}"
124
  except Exception as e:
125
  error_message = f"Error: {str(e)}"
126
+ history.append({"role": "user", "content": question})
127
+ history.append({"role": "assistant", "content": error_message})
128
  return history, "", "Remaining queries this hour: 5/5"
129
 
130
  def clear_chat():