Matthew commited on
Commit
692a76c
·
1 Parent(s): 81917a3

Moved agent logic into separate file

Browse files
Files changed (4) hide show
  1. agent.py +8 -0
  2. app.py +4 -9
  3. pyproject.toml +10 -0
  4. requirements.txt +0 -2
agent.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ class DRAgent:
2
+ def __init__(self):
3
+ print("BasicAgent initialized.")
4
+ def __call__(self, question: str) -> str:
5
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
6
+ fixed_answer = "This is a default answer."
7
+ print(f"Agent returning fixed answer: {fixed_answer}")
8
+ return fixed_answer
app.py CHANGED
@@ -4,20 +4,15 @@ import requests
4
  import inspect
5
  import pandas as pd
6
 
 
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  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
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
@@ -40,7 +35,7 @@ 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
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ from agent import DRAgent
8
+
9
  # (Keep Constants as is)
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
+ # NB: Moved to `agent.py`
 
 
 
 
 
 
 
16
 
17
  def run_and_submit_all( profile: gr.OAuthProfile | None):
18
  """
 
35
 
36
  # 1. Instantiate Agent ( modify this part to create your agent)
37
  try:
38
+ agent = DRAgent()
39
  except Exception as e:
40
  print(f"Error instantiating agent: {e}")
41
  return f"Error initializing agent: {e}", None
pyproject.toml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "agents-course-final-assignment"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = [
8
+ "gradio>=5.49.1",
9
+ "requests>=2.32.5",
10
+ ]
requirements.txt DELETED
@@ -1,2 +0,0 @@
1
- gradio
2
- requests