Toumaima commited on
Commit
dd41141
·
verified ·
1 Parent(s): beb1edf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -28,10 +28,13 @@ class BasicAgent:
28
  result = self.whisper_model.transcribe(audio_path)
29
  return result["text"]
30
 
31
- def search(self, question: str) -> str:
32
- # Perform a DuckDuckGo search for an answer to the question
33
- search_results = DDGS(question)
34
- return search_results[0]["body"] if search_results else "No relevant search results found."
 
 
 
35
 
36
  def __call__(self, question: str, video_path: str = None) -> str:
37
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
28
  result = self.whisper_model.transcribe(audio_path)
29
  return result["text"]
30
 
31
+ def __call__(self, question: str) -> str:
32
+ try:
33
+ with DDGS() as ddgs:
34
+ results = list(ddgs.text(question, max_results=1))
35
+ return results[0]["body"] if results else "No relevant search results found."
36
+ except Exception as e:
37
+ return f"Search error: {e}"
38
 
39
  def __call__(self, question: str, video_path: str = None) -> str:
40
  print(f"Agent received question (first 50 chars): {question[:50]}...")