zakerytclarke commited on
Commit
eae27f8
·
verified ·
1 Parent(s): 8e6d75f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -139,14 +139,15 @@ async def handle_chat(user_input):
139
 
140
  else: # Search task
141
  search_start_time = time.time()
142
- results = await brave_search(user_input)
 
 
 
 
 
 
 
143
  search_end_time = time.time()
144
-
145
- if len(results)==0:
146
- return "I'm sorry but I don't have any information on that.", ""
147
- documents = [desc.replace('<strong>', '').replace('</strong>', '') for _, desc, _ in results]
148
-
149
- context = "\n".join(documents)
150
 
151
  generation_start_time = time.time()
152
  response = await query_teapot(prompt, context, user_input)
@@ -199,9 +200,9 @@ async def on_message(message):
199
 
200
  print(message.content)
201
 
202
- is_debug = "debug:" in message.content
203
  async with message.channel.typing():
204
- cleaned_message=message.content.replace("debug:", "").replace(f'<@{client.user.id}>',"")
205
  response, debug_info = await handle_chat(cleaned_message)
206
  print(response)
207
  sent_message = await message.reply(response)
 
139
 
140
  else: # Search task
141
  search_start_time = time.time()
142
+ if len(user_input)<400 and "context:" not in user_input and "Context:" not in user_input:
143
+ results = await brave_search(user_input)
144
+ if len(results)==0: # No information
145
+ return "I'm sorry but I don't have any information on that.", ""
146
+ documents = [desc.replace('<strong>', '').replace('</strong>', '') for _, desc, _ in results]
147
+ context = "\n".join(documents)
148
+ else:
149
+ context="" # User provide context
150
  search_end_time = time.time()
 
 
 
 
 
 
151
 
152
  generation_start_time = time.time()
153
  response = await query_teapot(prompt, context, user_input)
 
200
 
201
  print(message.content)
202
 
203
+ is_debug = "debug:" in message.content or "Debug:" in message.content
204
  async with message.channel.typing():
205
+ cleaned_message=message.content.replace("debug:", "").replace("Debug:","").replace(f'<@{client.user.id}>',"")
206
  response, debug_info = await handle_chat(cleaned_message)
207
  print(response)
208
  sent_message = await message.reply(response)