Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import pandas as pd
|
| 5 |
# ADDED BY BEYZAPEHLIVAN
|
| 6 |
-
from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -12,22 +12,30 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
# --- YENİ ALFRED AJANI ---
|
| 14 |
token = os.getenv("HF_TOKEN")
|
| 15 |
-
model = HfApiModel(model_id="
|
| 16 |
|
| 17 |
class AlfredAgent:
|
| 18 |
def __init__(self):
|
| 19 |
-
#
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
| 25 |
)
|
| 26 |
print("AlfredAgent başarıyla kuruldu.")
|
| 27 |
|
| 28 |
def __call__(self, question: str) -> str:
|
| 29 |
-
prompt = f"""
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
Task: {question}"""
|
| 32 |
try:
|
| 33 |
result = self.agent.run(prompt)
|
|
|
|
| 3 |
import requests
|
| 4 |
import pandas as pd
|
| 5 |
# ADDED BY BEYZAPEHLIVAN
|
| 6 |
+
from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool, VisitWebpageTool
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
# --- YENİ ALFRED AJANI ---
|
| 14 |
token = os.getenv("HF_TOKEN")
|
| 15 |
+
model = HfApiModel(model_id="Qwen/Qwen2.5-72B-Instruct", token=token)
|
| 16 |
|
| 17 |
class AlfredAgent:
|
| 18 |
def __init__(self):
|
| 19 |
+
# VisitWebpageTool: Web sayfalarının içeriğini okumasını sağlar.
|
| 20 |
+
# DuckDuckGoSearchTool: Arama yapmasını sağlar.
|
| 21 |
+
self.agent = CodeAgent(
|
| 22 |
+
tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
|
| 23 |
+
model=model,
|
| 24 |
+
max_steps=12, # Adım sayısını artırdık
|
| 25 |
+
add_base_tools=True
|
| 26 |
)
|
| 27 |
print("AlfredAgent başarıyla kuruldu.")
|
| 28 |
|
| 29 |
def __call__(self, question: str) -> str:
|
| 30 |
+
prompt = f"""You are a world-class solver for the GAIA benchmark.
|
| 31 |
+
Solve the task below and provide ONLY the absolute final result.
|
| 32 |
+
|
| 33 |
+
RULES:
|
| 34 |
+
- If the answer is a name, provide only the name (e.g., 'Albert Einstein').
|
| 35 |
+
- If the answer is a number, provide only the digits (e.g., '14.5').
|
| 36 |
+
- If the answer is a date, use YYYY-MM-DD format.
|
| 37 |
+
- NO EXPLANATIONS. NO "The answer is...". NO punctuation at the end.
|
| 38 |
+
|
| 39 |
Task: {question}"""
|
| 40 |
try:
|
| 41 |
result = self.agent.run(prompt)
|