Spaces:
Sleeping
Sleeping
Update app.py
Browse files133 unmodified lines13413513613713813914014114214314414514614714814915015115218 unmodified lines17117217317417517617717817918016 unmodified lines197198199133 unmodified linesraw = GaiaQATool()._run(q)ans = normalize_answer(raw)else:# 3.2 Проверка наличия вложенного файлаhas_file = any(k in item for k in ("file", "file_url", "attachment"))file_url = f"{api_url}/files/{tid}" if has_file else None# 3.3 Прямое исполнение .py, если это скриптif file_url and file_url.lower().endswith(".py"):raw = PythonExecTool()._run(file_url)ans = normalize_answer(raw)else:# 3.4 Общий проход через агентаprompt = qif file_url:prompt += f"\nFilePath: {file_url}"raw = agent.invoke(prompt)if hasattr(raw, "content"):raw = raw.content18 unmodified linesresp2.raise_for_status()data = resp2.json()status = (f"Submission Successful!\n"f"User: {data.get('username')}\n"f"Score: {data.get('score','N/A')} ({data.get('correct_count','?')}/"f"{data.get('total_attempted','?')})\n"f"{data.get('message','')}")except Exception as e:16 unmodified lines133 unmodified lines13413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416518 unmodified lines18418518618718818919019119219319419519616 unmodified lines213214215216133 unmodified linesraw = GaiaQATool()._run(q)ans = normalize_answer(raw)else:# 3.2 Проверка и загрузка вложенного файла через APIfile_entry = item.get("file") or item.get("file_url") or item.get("attachment")file_path = Noneif file_entry:try:resp = requests.get(f"{api_url}/files/{tid}", timeout=15)resp.raise_for_status()# определяем расширениеext = os.path.splitext(str(file_entry))[-1] or ""tmp_path = f"/tmp/{tid}{ext}"with open(tmp_path, "wb") as f:f.write(resp.content)file_path = tmp_pathexcept Exception:file_path = None# 3.3 Прямое исполнение .py, если это скриптif file_path and file_path.lower().endswith(".py"):raw = PythonExecTool()._run(file_path)ans = normalize_answer(raw)else:# 3.4 Общий проход через агентаprompt = qif file_path:prompt += f"FilePath: {file_path}"raw = agent.invoke(prompt)if hasattr(raw, "content"):raw = raw.content18 unmodified linesresp2.raise_for_status()data = resp2.json()status = (f"Submission Successful!"f"User: {data.get('username')}"f"Score: {data.get('score','N/A')} ({data.get('correct_count','?')}/"f"{data.get('total_attempted','?')})"f"{data.get('message','')}")except Exception as e:16 unmodified lines
app.py+27-10