Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,8 +27,7 @@ class BasicAgent:
|
|
| 27 |
model_name="deepseek-ai/DeepSeek-R1-0528",
|
| 28 |
token=self.api_key,
|
| 29 |
provider="auto",
|
| 30 |
-
max_iterations=10
|
| 31 |
-
max_execution_time=60
|
| 32 |
)
|
| 33 |
self.agent = AgentWorkflow.from_tools_or_functions(
|
| 34 |
[wikipedia_search_tool, youtube_transcript_tool, youtube_transcript_snippet_tool,
|
|
@@ -56,8 +55,20 @@ class BasicAgent:
|
|
| 56 |
|
| 57 |
# START MY CODE
|
| 58 |
|
| 59 |
-
print("BasicAgent initialized.")
|
| 60 |
-
api_key = os.getenv("HF_TOKEN")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
# END MY CODE
|
| 63 |
|
|
@@ -66,20 +77,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 66 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 67 |
and displays the results.
|
| 68 |
"""
|
| 69 |
-
|
| 70 |
-
llm = HuggingFaceInferenceAPI(
|
| 71 |
-
model_name="deepseek-ai/DeepSeek-R1-0528",
|
| 72 |
-
token=api_key,
|
| 73 |
-
provider="auto",
|
| 74 |
-
max_iterations=10,
|
| 75 |
-
max_execution_time=60
|
| 76 |
-
)
|
| 77 |
-
agent = AgentWorkflow.from_tools_or_functions(
|
| 78 |
-
[wikipedia_search_tool, youtube_transcript_tool, youtube_transcript_snippet_tool,
|
| 79 |
-
round_to_two_decimals_tool, text_inverter_tool, google_web_search_tool],
|
| 80 |
-
llm=llm
|
| 81 |
-
)
|
| 82 |
-
|
| 83 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 84 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 85 |
|
|
@@ -95,11 +92,11 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 95 |
submit_url = f"{api_url}/submit"
|
| 96 |
|
| 97 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
#In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 104 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 105 |
print(agent_code)
|
|
|
|
| 27 |
model_name="deepseek-ai/DeepSeek-R1-0528",
|
| 28 |
token=self.api_key,
|
| 29 |
provider="auto",
|
| 30 |
+
max_iterations=10
|
|
|
|
| 31 |
)
|
| 32 |
self.agent = AgentWorkflow.from_tools_or_functions(
|
| 33 |
[wikipedia_search_tool, youtube_transcript_tool, youtube_transcript_snippet_tool,
|
|
|
|
| 55 |
|
| 56 |
# START MY CODE
|
| 57 |
|
| 58 |
+
# print("BasicAgent initialized.")
|
| 59 |
+
# api_key = os.getenv("HF_TOKEN")
|
| 60 |
+
# llm = HuggingFaceInferenceAPI(
|
| 61 |
+
# model_name="deepseek-ai/DeepSeek-R1-0528",
|
| 62 |
+
# token=api_key,
|
| 63 |
+
# provider="auto",
|
| 64 |
+
# max_iterations=10,
|
| 65 |
+
# max_execution_time=60
|
| 66 |
+
# )
|
| 67 |
+
# agent = AgentWorkflow.from_tools_or_functions(
|
| 68 |
+
# [wikipedia_search_tool, youtube_transcript_tool, youtube_transcript_snippet_tool,
|
| 69 |
+
# round_to_two_decimals_tool, text_inverter_tool, google_web_search_tool],
|
| 70 |
+
# llm=llm
|
| 71 |
+
# )
|
| 72 |
|
| 73 |
# END MY CODE
|
| 74 |
|
|
|
|
| 77 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 78 |
and displays the results.
|
| 79 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 81 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 82 |
|
|
|
|
| 92 |
submit_url = f"{api_url}/submit"
|
| 93 |
|
| 94 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 95 |
+
try:
|
| 96 |
+
agent = BasicAgent()
|
| 97 |
+
except Exception as e:
|
| 98 |
+
print(f"Error instantiating agent: {e}")
|
| 99 |
+
return f"Error initializing agent: {e}", None
|
| 100 |
#In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 101 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 102 |
print(agent_code)
|