Pijush2023 commited on
Commit
3ccf668
·
verified ·
1 Parent(s): d9258b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -64
app.py CHANGED
@@ -277,48 +277,11 @@ def generate_answer(message, choice, retrieval_mode):
277
  else:
278
  return "Invalid retrieval mode selected.", []
279
 
280
- # def bot(history, choice, tts_choice, retrieval_mode):
281
- # if not history:
282
- # return history
283
-
284
- # response, addresses = generate_answer(history[-1][0], choice, retrieval_mode)
285
- # history[-1][1] = ""
286
-
287
- # with concurrent.futures.ThreadPoolExecutor() as executor:
288
- # if tts_choice == "Alpha":
289
- # audio_future = executor.submit(generate_audio_elevenlabs, response)
290
- # elif tts_choice == "Beta":
291
- # audio_future = executor.submit(generate_audio_parler_tts, response)
292
- # elif tts_choice == "Gamma":
293
- # audio_future = executor.submit(generate_audio_mars5, response)
294
-
295
- # for character in response:
296
- # history[-1][1] += character
297
- # time.sleep(0.05)
298
- # yield history, None
299
-
300
- # audio_path = audio_future.result()
301
- # yield history, audio_path
302
-
303
- # history.append([response, None]) # Ensure the response is added in the correct format
304
-
305
-
306
  def bot(history, choice, tts_choice, retrieval_mode):
307
  if not history:
308
  return history
309
 
310
- user_message = history[-1][0]
311
- response = ""
312
- addresses = []
313
-
314
- # Check if the question is about restaurants
315
- if "restaurant" in user_message.lower():
316
- # Use the agent to get the response
317
- response = agent.run(user_message)
318
- else:
319
- # Otherwise, use the existing logic
320
- response, addresses = generate_answer(user_message, choice, retrieval_mode)
321
-
322
  history[-1][1] = ""
323
 
324
  with concurrent.futures.ThreadPoolExecutor() as executor:
@@ -340,6 +303,7 @@ def bot(history, choice, tts_choice, retrieval_mode):
340
  history.append([response, None]) # Ensure the response is added in the correct format
341
 
342
 
 
343
  def add_message(history, message):
344
  history.append((message, None))
345
  return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
@@ -692,32 +656,6 @@ def update_images():
692
 
693
 
694
 
695
- #Crew AI Integration
696
-
697
- from crewai import Agent
698
- from langchain.agents import Tool
699
- from langchain.utilities import GoogleSerperAPIWrapper
700
-
701
- # Setup API keys
702
- os.environ["SERP_API"] = "Your Key"
703
-
704
- search = GoogleSerperAPIWrapper()
705
-
706
- # Create and assign the search tool to an agent
707
- serper_tool = Tool(
708
- name="Intermediate Answer",
709
- func=search.run,
710
- description="Useful for search-based queries",
711
- )
712
-
713
- agent = Agent(
714
- role='Research Analyst',
715
- goal='Provide up-to-date market analysis',
716
- backstory='An expert analyst with a keen eye for market trends.',
717
- tools=[serper_tool]
718
- )
719
-
720
-
721
 
722
  def fetch_local_events():
723
  api_key = os.environ['SERP_API']
 
277
  else:
278
  return "Invalid retrieval mode selected.", []
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  def bot(history, choice, tts_choice, retrieval_mode):
281
  if not history:
282
  return history
283
 
284
+ response, addresses = generate_answer(history[-1][0], choice, retrieval_mode)
 
 
 
 
 
 
 
 
 
 
 
285
  history[-1][1] = ""
286
 
287
  with concurrent.futures.ThreadPoolExecutor() as executor:
 
303
  history.append([response, None]) # Ensure the response is added in the correct format
304
 
305
 
306
+
307
  def add_message(history, message):
308
  history.append((message, None))
309
  return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
 
656
 
657
 
658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
659
 
660
  def fetch_local_events():
661
  api_key = os.environ['SERP_API']