Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
-
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, LiteLLMModel, ToolCallingAgent, tool, WikipediaSearchTool
|
7 |
|
8 |
# (Keep Constants as is)
|
9 |
# --- Constants ---
|
@@ -11,9 +11,10 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
11 |
|
12 |
os.environ['MISTRAL_API_KEY'] = "pP4zBHul9WEk7msQNymtXby3yxhy38it"
|
13 |
|
14 |
-
model =
|
15 |
-
|
16 |
-
|
|
|
17 |
|
18 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
19 |
"""
|
@@ -80,7 +81,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
80 |
print(f"Skipping item with missing task_id or question: {item}")
|
81 |
continue
|
82 |
try:
|
83 |
-
submitted_answer = agent.run(question_text)
|
84 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
85 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
86 |
except Exception as e:
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, LiteLLMModel, ToolCallingAgent, tool, OpenAIServerModel, WikipediaSearchTool
|
7 |
|
8 |
# (Keep Constants as is)
|
9 |
# --- Constants ---
|
|
|
11 |
|
12 |
os.environ['MISTRAL_API_KEY'] = "pP4zBHul9WEk7msQNymtXby3yxhy38it"
|
13 |
|
14 |
+
model = OpenAIServerModel(model_id="gpt-4o")
|
15 |
+
#model = LiteLLMModel(model_id="mistral/mistral-large-latest")
|
16 |
+
|
17 |
+
prompt = "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
18 |
|
19 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
20 |
"""
|
|
|
81 |
print(f"Skipping item with missing task_id or question: {item}")
|
82 |
continue
|
83 |
try:
|
84 |
+
submitted_answer = agent.run(prompt + " " + question_text)
|
85 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
86 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
87 |
except Exception as e:
|