beyzapehlivan commited on
Commit
6bb6b06
·
verified ·
1 Parent(s): e157d3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
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="meta-llama/Llama-3.1-8B-Instruct", token=token)
16
 
17
  class AlfredAgent:
18
  def __init__(self):
19
- # DuckDuckGoSearchTool'u listeden çıkarıyoruz çünkü
20
- # add_base_tools=True onu zaten otomatik getiriyor.
21
- self.agent = CodeAgent(
22
- tools=[],
23
- model=model,
24
- add_base_tools=True
 
25
  )
26
  print("AlfredAgent başarıyla kuruldu.")
27
 
28
  def __call__(self, question: str) -> str:
29
- prompt = f"""Solve this task. Provide ONLY the final answer without any explanation.
30
- If it's a number, just give the number. If it's a name, just the name.
 
 
 
 
 
 
 
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)