Update app.py
Browse files
app.py
CHANGED
|
@@ -10,13 +10,14 @@ from smolagents import GradioUI, CodeAgent, HfApiModel, PythonInterpreterTool
|
|
| 10 |
# --- Constants ---
|
| 11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 12 |
|
|
|
|
|
|
|
| 13 |
# --- Basic Agent Definition ---
|
| 14 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
print("BasicAgent initialized.")
|
| 18 |
def __call__(self, question: str) -> str:
|
| 19 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 20 |
web_search = Web_research()
|
| 21 |
image_tool = image_interpreter()
|
| 22 |
python_code_tool = PythonInterpreterTool()
|
|
@@ -33,9 +34,10 @@ class BasicAgent:
|
|
| 33 |
headers = {
|
| 34 |
"Authorization": f"Bearer {HF_TOKEN}"
|
| 35 |
}
|
| 36 |
-
print("Agent
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 41 |
"""
|
|
@@ -208,5 +210,5 @@ if __name__ == "__main__":
|
|
| 208 |
|
| 209 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 210 |
|
| 211 |
-
print("Launching Gradio Interface for Agent Evaluation...")
|
| 212 |
demo.launch(debug=True, share=False)
|
|
|
|
| 10 |
# --- Constants ---
|
| 11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 12 |
|
| 13 |
+
# --- Basic Agent Definition ---
|
| 14 |
+
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 15 |
# --- Basic Agent Definition ---
|
| 16 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 17 |
class BasicAgent:
|
| 18 |
def __init__(self):
|
| 19 |
print("BasicAgent initialized.")
|
| 20 |
def __call__(self, question: str) -> str:
|
|
|
|
| 21 |
web_search = Web_research()
|
| 22 |
image_tool = image_interpreter()
|
| 23 |
python_code_tool = PythonInterpreterTool()
|
|
|
|
| 34 |
headers = {
|
| 35 |
"Authorization": f"Bearer {HF_TOKEN}"
|
| 36 |
}
|
| 37 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 38 |
+
fixed_answer = alfred.run(f"You are a general AI assistant. I will ask you a question. You have tools to answer them, always check it before anything else. Mainly, you can extract the full content of wikipedia pages, do web searches and you have a tool for multimodal inputs. You must use them in priority if needed, before thinking of anything else. 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. Here are the questions : {question}")
|
| 39 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 40 |
+
return fixed_answer
|
| 41 |
|
| 42 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 43 |
"""
|
|
|
|
| 210 |
|
| 211 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 212 |
|
| 213 |
+
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 214 |
demo.launch(debug=True, share=False)
|