Spaces:
Sleeping
Sleeping
Update tools.py
Browse files
tools.py
CHANGED
@@ -143,17 +143,19 @@ def parse_excel_tool(state: AgentState) -> AgentState:
|
|
143 |
Always attempts to download the file for the given path or task ID.
|
144 |
"""
|
145 |
print("reached parse_excel_tool")
|
|
|
146 |
path_or_id = state.get("excel_path", "")
|
147 |
sheet = state.get("excel_sheet_name", "")
|
148 |
if not path_or_id:
|
149 |
return {}
|
150 |
|
151 |
# Always attempt to download the file, regardless of local existence
|
152 |
-
|
153 |
|
154 |
# If we finally have a real file, read it
|
155 |
if local_xlsx and os.path.exists(local_xlsx):
|
156 |
try:
|
|
|
157 |
xls = pd.ExcelFile(local_xlsx)
|
158 |
if sheet and sheet in xls.sheet_names:
|
159 |
df = pd.read_excel(xls, sheet_name=sheet)
|
@@ -257,10 +259,10 @@ def audio_transcriber_tool(state: AgentState) -> AgentState:
|
|
257 |
raise RuntimeError("OPENAI_API_KEY is not set in environment.")
|
258 |
|
259 |
with open(local_audio, "rb") as audio_file:
|
260 |
-
response = openai.transcriptions.create(
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
text = response.get("text", "").strip()
|
265 |
except Exception as e:
|
266 |
text = f"Error during transcription: {e}"
|
|
|
143 |
Always attempts to download the file for the given path or task ID.
|
144 |
"""
|
145 |
print("reached parse_excel_tool")
|
146 |
+
local_xlsx = _download_file_for_task(state.get("task_id"), "xlsx")
|
147 |
path_or_id = state.get("excel_path", "")
|
148 |
sheet = state.get("excel_sheet_name", "")
|
149 |
if not path_or_id:
|
150 |
return {}
|
151 |
|
152 |
# Always attempt to download the file, regardless of local existence
|
153 |
+
|
154 |
|
155 |
# If we finally have a real file, read it
|
156 |
if local_xlsx and os.path.exists(local_xlsx):
|
157 |
try:
|
158 |
+
print("reached excel file found")
|
159 |
xls = pd.ExcelFile(local_xlsx)
|
160 |
if sheet and sheet in xls.sheet_names:
|
161 |
df = pd.read_excel(xls, sheet_name=sheet)
|
|
|
259 |
raise RuntimeError("OPENAI_API_KEY is not set in environment.")
|
260 |
|
261 |
with open(local_audio, "rb") as audio_file:
|
262 |
+
response = openai.audio.transcriptions.create(
|
263 |
+
model="whisper-1",
|
264 |
+
file=audio_file,
|
265 |
+
)
|
266 |
text = response.get("text", "").strip()
|
267 |
except Exception as e:
|
268 |
text = f"Error during transcription: {e}"
|