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 lines678910111213 unmodified lines262728293031328 unmodified lines4142434445464787 unmodified lines1351361371381391401415 unmodified linesimport pandas as pdimport requestsfrom smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, Tool, VisitWebpageToolfrom tools import WikipediaSummaryTool, WikipediaPageTool, YouTubeVisionAnalyzer, YouTubeTranscriptTool, AudioFileTranscriptTool, PythonFileReader, ExcelFileLoaderfrom vision_llm import call_vision_llmfrom final_answer_llm import check_final_answer13 unmodified lines# Initialize the LLMmodel = OpenAIServerModel(api_key=OPENAI_API_KEY,model_id='gpt-4o-mini',temperature=0,)self.model = model8 unmodified linesYouTubeVisionAnalyzer(),YouTubeTranscriptTool(),AudioFileTranscriptTool(),PythonFileReader(),ExcelFileLoader(),call_vision_llm,],87 unmodified lines# 3. Run your Agentresults_log = []answers_payload = []questions_data = [questions_data[3], questions_data[9], questions_data[11], questions_data[18]] # Remove this laterprint(f"Running agent on {len(questions_data)} questions...")for item in questions_data:task_id = item.get("task_id")5 unmodified lines678910111213 unmodified lines262728293031328 unmodified lines4142434445464787 unmodified lines1351361371381391401415 unmodified linesimport pandas as pdimport requestsfrom smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, Tool, VisitWebpageToolfrom tools import WikipediaSummaryTool, WikipediaPageTool, YouTubeVisionAnalyzer, YouTubeTranscriptTool, AudioFileTranscriptTool, PythonFileDownloader, ExcelFileLoaderfrom vision_llm import call_vision_llmfrom final_answer_llm import check_final_answer13 unmodified lines# Initialize the LLMmodel = OpenAIServerModel(api_key=OPENAI_API_KEY,model_id='gpt-4.1-mini',temperature=0,)self.model = model8 unmodified linesYouTubeVisionAnalyzer(),YouTubeTranscriptTool(),AudioFileTranscriptTool(),PythonFileDownloader(),ExcelFileLoader(),call_vision_llm,],87 unmodified lines# 3. Run your Agentresults_log = []answers_payload = []questions_data = [questions_data[11]] # Remove this laterprint(f"Running agent on {len(questions_data)} questions...")for item in questions_data:task_id = item.get("task_id")
2 unmodified lines345678910119 unmodified lines212223242526272 unmodified linessystem_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"."""9 unmodified linesanswer_model = OpenAIServerModel(api_key=OPENAI_API_KEY,model_id='gpt-4o-mini',temperature=0,)2 unmodified lines345678910119 unmodified lines212223242526272 unmodified linessystem_text = """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 linesanswer_model = OpenAIServerModel(api_key=OPENAI_API_KEY,model_id='gpt-4.1-mini',temperature=0,)
316 unmodified lines31731831932032132232332432519 unmodified lines34534634734834935035135235335428 unmodified lines383384385386387316 unmodified linesreturn 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."inputs = {"file_id": {"type": "string",19 unmodified linesresponse = get_file_content(file_id, file_url)# Decode bytes to textcode_content = response.content.decode("utf-8")return code_contentclass ExcelFileLoader(Tool):28 unmodified lineswith open("sheet.xlsx", "wb") as f:f.write(response.content)return "sheet.xlsx"316 unmodified lines31731831932032132232332432519 unmodified lines34534634734834935035135235335435528 unmodified lines384385386387316 unmodified linesreturn result['text']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 linesresponse = get_file_content(file_id, file_url)# Save bytes to a Python filewith open("code.py", "wb") as f:f.write(response.content)return "The file is available as 'code.py'."class ExcelFileLoader(Tool):28 unmodified lineswith open("sheet.xlsx", "wb") as f:f.write(response.content)return "The file is available as 'sheet.xlsx'."
app.py+4-4
final_answer_llm.py+4-4
tools.py+8-8