wt002 commited on
Commit
a62ad11
·
verified ·
1 Parent(s): be88841

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -28,7 +28,7 @@ class BasicAgent:
28
  #print(agent.generate("Explain quantum computing"))
29
 
30
 
31
- def __call__(self, question: str) -> str:
32
  print(f"Agent received question (first 50 chars): {question[:50]}...")
33
  fixed_answer = self.agent.generate(question)
34
  print(f"Agent returning answer: {fixed_answer}")
@@ -36,7 +36,7 @@ class BasicAgent:
36
 
37
 
38
  # to check
39
- def generate_response(self, prompt: str) -> str:
40
  """Get response from Gema"""
41
  try:
42
  response = self.model.generate_content(prompt)
@@ -46,7 +46,7 @@ class BasicAgent:
46
 
47
 
48
 
49
- def web_search(self, query: str) -> List[Dict]:
50
  """Use SearxNG meta-search engine"""
51
  params = {
52
  "q": query,
@@ -60,12 +60,12 @@ class BasicAgent:
60
  except requests.RequestException:
61
  return []
62
 
63
- def wikipedia_search(self, query: str) -> str:
64
  """Get Wikipedia summary"""
65
  page = self.wiki.page(query)
66
  return page.summary if page.exists() else "No Wikipedia page found"
67
 
68
- def process_document(self, file_path: str) -> str:
69
  """Handle PDF, Word, CSV, Excel files"""
70
  if not os.path.exists(file_path):
71
  return "File not found"
@@ -86,7 +86,7 @@ class BasicAgent:
86
  except Exception as e:
87
  return f"Error processing document: {str(e)}"
88
 
89
- def _process_pdf(self, file_path: str) -> str:
90
  """Process PDF using Gemini's vision capability"""
91
  try:
92
  # For Gemini 1.5 or later which supports file uploads
@@ -106,7 +106,7 @@ class BasicAgent:
106
  except ImportError:
107
  return "PDF processing requires PyPDF2 (pip install PyPDF2)"
108
 
109
- def _process_word(self, file_path: str) -> str:
110
  """Process Word documents"""
111
  try:
112
  from docx import Document
@@ -115,7 +115,7 @@ class BasicAgent:
115
  except ImportError:
116
  return "Word processing requires python-docx (pip install python-docx)"
117
 
118
- def process_request(self, request: Union[str, Dict]) -> str:
119
  """
120
  Handle different request types:
121
  - Direct text queries
 
28
  #print(agent.generate("Explain quantum computing"))
29
 
30
 
31
+ def __call__(self, question: str) -> str:
32
  print(f"Agent received question (first 50 chars): {question[:50]}...")
33
  fixed_answer = self.agent.generate(question)
34
  print(f"Agent returning answer: {fixed_answer}")
 
36
 
37
 
38
  # to check
39
+ def generate_response(self, prompt: str) -> str:
40
  """Get response from Gema"""
41
  try:
42
  response = self.model.generate_content(prompt)
 
46
 
47
 
48
 
49
+ def web_search(self, query: str) -> List[Dict]:
50
  """Use SearxNG meta-search engine"""
51
  params = {
52
  "q": query,
 
60
  except requests.RequestException:
61
  return []
62
 
63
+ def wikipedia_search(self, query: str) -> str:
64
  """Get Wikipedia summary"""
65
  page = self.wiki.page(query)
66
  return page.summary if page.exists() else "No Wikipedia page found"
67
 
68
+ def process_document(self, file_path: str) -> str:
69
  """Handle PDF, Word, CSV, Excel files"""
70
  if not os.path.exists(file_path):
71
  return "File not found"
 
86
  except Exception as e:
87
  return f"Error processing document: {str(e)}"
88
 
89
+ def _process_pdf(self, file_path: str) -> str:
90
  """Process PDF using Gemini's vision capability"""
91
  try:
92
  # For Gemini 1.5 or later which supports file uploads
 
106
  except ImportError:
107
  return "PDF processing requires PyPDF2 (pip install PyPDF2)"
108
 
109
+ def _process_word(self, file_path: str) -> str:
110
  """Process Word documents"""
111
  try:
112
  from docx import Document
 
115
  except ImportError:
116
  return "Word processing requires python-docx (pip install python-docx)"
117
 
118
+ def process_request(self, request: Union[str, Dict]) -> str:
119
  """
120
  Handle different request types:
121
  - Direct text queries