ThatOneKevDev commited on
Commit
7db7be1
·
verified ·
1 Parent(s): 9bf192f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -42,7 +42,7 @@ except Exception as e:
42
 
43
  def load_and_preprocess_text(filename):
44
  """
45
- Load and preprocess text from a file, removing empty lines and stripping whitespace.
46
  """
47
  try:
48
  with open(filename, 'r', encoding='utf-8') as file:
@@ -57,8 +57,8 @@ segments = load_and_preprocess_text(filename)
57
 
58
  def find_relevant_segment(user_query, segments):
59
  """
60
- Find the most relevant text segment for a user's query using cosine similarity among sentence embeddings.
61
- This version finds the best match based on the content of the query.
62
  """
63
  try:
64
  # Lowercase the query for better matching
@@ -82,7 +82,7 @@ def find_relevant_segment(user_query, segments):
82
 
83
  def generate_response(user_query, relevant_segment):
84
  """
85
- Generate a response emphasizing the bot's capability in providing information about St. Louis events.
86
  """
87
  try:
88
  system_message = "You are a chatbot specialized in providing information on local events, pro-Palestine movements, and community outreach, pride movements/events and community resources."
@@ -107,7 +107,7 @@ def generate_response(user_query, relevant_segment):
107
 
108
  def query_model(question):
109
  """
110
- Process a question, find relevant information, and generate a response.
111
  """
112
  if question == "":
113
  return "Welcome to GloBot! Ask me anything about the St. Louis Community!"
 
42
 
43
  def load_and_preprocess_text(filename):
44
  """
45
+ # Load and preprocess text from a file, removing empty lines and stripping whitespace.
46
  """
47
  try:
48
  with open(filename, 'r', encoding='utf-8') as file:
 
57
 
58
  def find_relevant_segment(user_query, segments):
59
  """
60
+ # Find the most relevant text segment for a user's query using cosine similarity among sentence embeddings.
61
+ # This version finds the best match based on the content of the query.
62
  """
63
  try:
64
  # Lowercase the query for better matching
 
82
 
83
  def generate_response(user_query, relevant_segment):
84
  """
85
+ # Generate a response emphasizing the bot's capability in providing information about St. Louis events.
86
  """
87
  try:
88
  system_message = "You are a chatbot specialized in providing information on local events, pro-Palestine movements, and community outreach, pride movements/events and community resources."
 
107
 
108
  def query_model(question):
109
  """
110
+ # Process a question, find relevant information, and generate a response.
111
  """
112
  if question == "":
113
  return "Welcome to GloBot! Ask me anything about the St. Louis Community!"