Synnove commited on
Commit
228df7a
·
verified ·
1 Parent(s): d0f351b

Implemented SmolAgent

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -10,11 +11,21 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
 
 
 
 
 
 
 
13
  class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
16
  def __call__(self, question: str) -> str:
17
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
18
  fixed_answer = "This is a default answer."
19
  print(f"Agent returning fixed answer: {fixed_answer}")
20
  return fixed_answer
@@ -40,7 +51,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
40
 
41
  # 1. Instantiate Agent ( modify this part to create your agent)
42
  try:
43
- agent = BasicAgent()
 
44
  except Exception as e:
45
  print(f"Error instantiating agent: {e}")
46
  return f"Error initializing agent: {e}", None
@@ -133,7 +145,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
133
  print(status_message)
134
  results_df = pd.DataFrame(results_log)
135
  return status_message, results_df
136
- except Exception as e:
137
  status_message = f"An unexpected error occurred during submission: {e}"
138
  print(status_message)
139
  results_df = pd.DataFrame(results_log)
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import SmolAgent, Tool, LLMFunction
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
 
11
 
12
  # --- Basic Agent Definition ---
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
+ #Tools
15
+
16
+
17
+ #LLM
18
+ llm = LLMFunction.from_local_model("mistralai/Mistral-7B-Instruct-v0.2")
19
+
20
+ #Agent
21
+ smolAgent = SmolAgent(llm=llm, tools = [])
22
+
23
  class BasicAgent:
24
  def __init__(self):
25
  print("BasicAgent initialized.")
26
  def __call__(self, question: str) -> str:
27
  print(f"Agent received question (first 50 chars): {question[:50]}...")
28
+
29
  fixed_answer = "This is a default answer."
30
  print(f"Agent returning fixed answer: {fixed_answer}")
31
  return fixed_answer
 
51
 
52
  # 1. Instantiate Agent ( modify this part to create your agent)
53
  try:
54
+ #agent = BasicAgent()
55
+ agent = smolAgent
56
  except Exception as e:
57
  print(f"Error instantiating agent: {e}")
58
  return f"Error initializing agent: {e}", None
 
145
  print(status_message)
146
  results_df = pd.DataFrame(results_log)
147
  return status_message, results_df
148
+ except run_and_submit_allxception as e:
149
  status_message = f"An unexpected error occurred during submission: {e}"
150
  print(status_message)
151
  results_df = pd.DataFrame(results_log)