Spaces:
Build error
Build error
Upload 5 files
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import pandas as pd
|
| 5 |
-
from utils import check_asnwer_format
|
| 6 |
import json
|
| 7 |
from smolagents import HfApiModel, CodeAgent, VisitWebpageTool
|
| 8 |
from tools import (
|
|
@@ -43,7 +42,7 @@ class AwesomeAgent:
|
|
| 43 |
model_id="meta-llama/Llama-3.3-70B-Instruct",
|
| 44 |
provider="hf-inference",
|
| 45 |
token=HF_TOKEN,
|
| 46 |
-
seed =
|
| 47 |
)
|
| 48 |
self.agent = CodeAgent(
|
| 49 |
model=model,
|
|
@@ -72,7 +71,6 @@ class AwesomeAgent:
|
|
| 72 |
],
|
| 73 |
planning_interval=3,
|
| 74 |
add_base_tools=True,
|
| 75 |
-
final_answer_checks=[check_asnwer_format],
|
| 76 |
)
|
| 77 |
print("AwesomeAgent initialized.")
|
| 78 |
|
|
@@ -185,8 +183,12 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 185 |
"answers": answers_payload,
|
| 186 |
}
|
| 187 |
|
|
|
|
|
|
|
|
|
|
| 188 |
status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
|
| 189 |
print(status_update)
|
|
|
|
| 190 |
|
| 191 |
# 5. Submit
|
| 192 |
print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import pandas as pd
|
|
|
|
| 5 |
import json
|
| 6 |
from smolagents import HfApiModel, CodeAgent, VisitWebpageTool
|
| 7 |
from tools import (
|
|
|
|
| 42 |
model_id="meta-llama/Llama-3.3-70B-Instruct",
|
| 43 |
provider="hf-inference",
|
| 44 |
token=HF_TOKEN,
|
| 45 |
+
seed = 100,
|
| 46 |
)
|
| 47 |
self.agent = CodeAgent(
|
| 48 |
model=model,
|
|
|
|
| 71 |
],
|
| 72 |
planning_interval=3,
|
| 73 |
add_base_tools=True,
|
|
|
|
| 74 |
)
|
| 75 |
print("AwesomeAgent initialized.")
|
| 76 |
|
|
|
|
| 183 |
"answers": answers_payload,
|
| 184 |
}
|
| 185 |
|
| 186 |
+
|
| 187 |
+
# return "Agent finished. Submitting answers", pd.DataFrame(results_log)
|
| 188 |
+
|
| 189 |
status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
|
| 190 |
print(status_update)
|
| 191 |
+
|
| 192 |
|
| 193 |
# 5. Submit
|
| 194 |
print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
|
utils.py
CHANGED
|
@@ -1,41 +1,11 @@
|
|
| 1 |
-
from
|
| 2 |
-
from dotenv import load_dotenv
|
| 3 |
from huggingface_hub import HfApi
|
| 4 |
-
import os
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
-
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
| 8 |
repo_id = "zaradana/temp_files"
|
| 9 |
|
| 10 |
api = HfApi()
|
| 11 |
|
| 12 |
-
def check_asnwer_format(final_answer, agent_memory):
|
| 13 |
-
multimodal_model = OpenAIServerModel("gpt-4o", max_tokens=8096, api_key=OPENAI_API_KEY)
|
| 14 |
-
prompt = (
|
| 15 |
-
f"Here is a user-given task and the agent steps: {agent_memory.get_succinct_steps()}. "
|
| 16 |
-
f"Here is the final answer: {final_answer}. "
|
| 17 |
-
"Please check that the answer is in the requested format. "
|
| 18 |
-
"First list reasons why yes/no, then write your final decision: PASS in caps lock if it is satisfactory, FAIL if it is not."
|
| 19 |
-
"Don't be harsh: if the answer is in the correct format, it should pass. "
|
| 20 |
-
)
|
| 21 |
-
messages = [
|
| 22 |
-
{
|
| 23 |
-
"role": "user",
|
| 24 |
-
"content": [
|
| 25 |
-
{
|
| 26 |
-
"type": "text",
|
| 27 |
-
"text": prompt,
|
| 28 |
-
}
|
| 29 |
-
],
|
| 30 |
-
}
|
| 31 |
-
]
|
| 32 |
-
output = multimodal_model(messages).content
|
| 33 |
-
print("Feedback: ", output)
|
| 34 |
-
if "FAIL" in output:
|
| 35 |
-
raise Exception(output)
|
| 36 |
-
return True
|
| 37 |
-
|
| 38 |
-
|
| 39 |
def upload_file(file_local_path: str) -> str:
|
| 40 |
"""
|
| 41 |
Upload a file to the Hugging Face Hub and return the URL
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
|
|
|
| 2 |
from huggingface_hub import HfApi
|
|
|
|
| 3 |
|
| 4 |
load_dotenv()
|
|
|
|
| 5 |
repo_id = "zaradana/temp_files"
|
| 6 |
|
| 7 |
api = HfApi()
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def upload_file(file_local_path: str) -> str:
|
| 10 |
"""
|
| 11 |
Upload a file to the Hugging Face Hub and return the URL
|