Spaces:
Runtime error
Runtime error
improved .py tool, final_answer and changed model to gpt-4.1-mini
Browse filesFiles changed (3)
- app.py+4-4
- final_answer_llm.py+4-4
- tools.py+8-8
5 unmodified lines6789910111213 unmodified lines26272829293031328 unmodified lines414243444445464787 unmodified lines1351361371381381391401415 unmodified linesimport pandas as pdimport requestsfrom smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, Tool, VisitWebpageToolfrom tools import WikipediaSummaryTool, WikipediaPageTool, YouTubeVisionAnalyzer, YouTubeTranscriptTool, AudioFileTranscriptTool, PythonFileReader, ExcelFileLoaderfrom tools import WikipediaSummaryTool, WikipediaPageTool, YouTubeVisionAnalyzer, YouTubeTranscriptTool, AudioFileTranscriptTool, PythonFileDownloader, ExcelFileLoaderfrom vision_llm import call_vision_llmfrom final_answer_llm import check_final_answer
13 unmodified lines # Initialize the LLM model = OpenAIServerModel( api_key=OPENAI_API_KEY, model_id='gpt-4o-mini', model_id='gpt-4.1-mini', temperature=0, ) self.model = model8 unmodified lines YouTubeVisionAnalyzer(), YouTubeTranscriptTool(), AudioFileTranscriptTool(), PythonFileReader(), PythonFileDownloader(), ExcelFileLoader(), call_vision_llm, ], 87 unmodified lines # 3. Run your Agent results_log = [] answers_payload = [] questions_data = [questions_data[3], questions_data[9], questions_data[11], questions_data[18]] # Remove this later questions_data = [questions_data[11]] # Remove this later print(f"Running agent on {len(questions_data)} questions...") for item in questions_data: task_id = item.get("task_id")2 unmodified lines345678678910119 unmodified lines21222324242526272 unmodified lines
system_text = """Your task is to make the given answer as concise as possible **without changing its meaning** or introducing any new information.Only shorten it by removing redundancy or unnecessary phrasing. You must preserve the original answer's facts and structure. Do not generate new content.Only output the revised answer. Do not include explanations or formatting like "Answer:" or "Final Answer".Revise the answer to match exactly what the question is asking. Keep it concise and focused, removing irrelevant details, redundant phrases, or formatting. Do not change the meaning or add new information. Ensure the output directly answers the question, with the correct level of specificity and format requested.Only return the revised answer. Do not include explanations or headers."""
9 unmodified lines
answer_model = OpenAIServerModel( api_key=OPENAI_API_KEY, model_id='gpt-4o-mini', model_id='gpt-4.1-mini', temperature=0, )
316 unmodified lines31731831932032132232032132232332432519 unmodified lines34534634734834934834935035135135235335435528 unmodified lines384385386386387387316 unmodified lines return result['text']
class PythonFileReader(Tool): name = "python_file_reader" description = "Extracts the full text content of a Python (.py) file so that it can be analyzed by the agent."class PythonFileDownloader(Tool): name = "python_file_downloader" description = "Downloads and stores a Python (.py) file locally as 'code.py' so it can be programmatically analyzed by the agent. This tool does not interpret or summarize the data itself — it only ensures the file is available in the environment." inputs = { "file_id": { "type": "string",19 unmodified lines
response = get_file_content(file_id, file_url)
# Decode bytes to text code_content = response.content.decode("utf-8") # Save bytes to a Python file with open("code.py", "wb") as f: f.write(response.content)
return code_content return "The file is available as 'code.py'."
class ExcelFileLoader(Tool):28 unmodified lines with open("sheet.xlsx", "wb") as f: f.write(response.content)
return "sheet.xlsx" return "The file is available as 'sheet.xlsx'." app.py+4-4
final_answer_llm.py+4-4
tools.py+8-8