ayush1603 commited on
Commit
062307f
Β·
verified Β·
1 Parent(s): 452d386

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -6,15 +6,15 @@ from typing import Optional
6
 
7
  import requests
8
  import pandas as pd
9
- import PyPDF2 # PDF reading library
10
- import pytesseract # OCR library
11
  from PIL import Image
12
 
13
- import gradio as gr # Gradio Blocks UI
14
- import litellm # LiteLLM client for Groq
15
  from litellm.integrations.opik.opik import OpikLogger
16
 
17
- from smolagents import tool, LiteLLMModel, CodeAgent , DuckDuckGoSearchTool, WikipediaSearchTool, SpeechToTextTool ,PythonInterpreterTool
18
 
19
  # ── 1) Read API keys from HF Spaces Secrets/Variables ───────────────────────
20
  GROQ_API_KEY = os.getenv("Grok_api")
@@ -39,6 +39,13 @@ llm = LiteLLMModel(
39
  def excel_to_text_tool(excel_path: str, sheet_name: Optional[str] = None) -> str:
40
  """
41
  Read an Excel file and return a Markdown table of the specified sheet.
 
 
 
 
 
 
 
42
  """
43
  path = Path(excel_path).expanduser().resolve()
44
  if not path.exists():
@@ -54,6 +61,13 @@ def excel_to_text_tool(excel_path: str, sheet_name: Optional[str] = None) -> str
54
  def pdf_to_text_tool(pdf_path: str) -> str:
55
  """
56
  Extract all text from a PDF file.
 
 
 
 
 
 
 
57
  """
58
  path = Path(pdf_path).expanduser().resolve()
59
  if not path.exists():
@@ -69,6 +83,13 @@ def pdf_to_text_tool(pdf_path: str) -> str:
69
  def analyze_image_tool(image_path: str) -> str:
70
  """
71
  Analyze an image: return dimensions and OCR-extracted text.
 
 
 
 
 
 
 
72
  """
73
  path = Path(image_path).expanduser().resolve()
74
  if not path.exists():
@@ -87,7 +108,6 @@ worker_agent = CodeAgent(
87
  tools=[
88
  DuckDuckGoSearchTool(),
89
  WikipediaSearchTool(),
90
- SpeechToTextTool(),
91
  excel_to_text_tool,
92
  pdf_to_text_tool,
93
  analyze_image_tool,
 
6
 
7
  import requests
8
  import pandas as pd
9
+ import PyPDF2
10
+ import pytesseract
11
  from PIL import Image
12
 
13
+ import gradio as gr
14
+ import litellm
15
  from litellm.integrations.opik.opik import OpikLogger
16
 
17
+ from smolagents import tool, LiteLLMModel, CodeAgent , DuckDuckGoSearchTool, WikipediaSearchTool ,PythonInterpreterTool
18
 
19
  # ── 1) Read API keys from HF Spaces Secrets/Variables ───────────────────────
20
  GROQ_API_KEY = os.getenv("Grok_api")
 
39
  def excel_to_text_tool(excel_path: str, sheet_name: Optional[str] = None) -> str:
40
  """
41
  Read an Excel file and return a Markdown table of the specified sheet.
42
+
43
+ Args:
44
+ excel_path: Path to the Excel file
45
+ query: Question about the data
46
+
47
+ Returns:
48
+ Analysis result or error message
49
  """
50
  path = Path(excel_path).expanduser().resolve()
51
  if not path.exists():
 
61
  def pdf_to_text_tool(pdf_path: str) -> str:
62
  """
63
  Extract all text from a PDF file.
64
+
65
+ Args:
66
+ pdf_path : Path to pdf's
67
+
68
+ Returns:
69
+ Analysis result or error message
70
+
71
  """
72
  path = Path(pdf_path).expanduser().resolve()
73
  if not path.exists():
 
83
  def analyze_image_tool(image_path: str) -> str:
84
  """
85
  Analyze an image: return dimensions and OCR-extracted text.
86
+
87
+ Args:
88
+ path : Image path
89
+
90
+ Returns:
91
+ Analysis result or error message
92
+
93
  """
94
  path = Path(image_path).expanduser().resolve()
95
  if not path.exists():
 
108
  tools=[
109
  DuckDuckGoSearchTool(),
110
  WikipediaSearchTool(),
 
111
  excel_to_text_tool,
112
  pdf_to_text_tool,
113
  analyze_image_tool,