sebastian commited on
Commit
a267ab6
·
1 Parent(s): ebb6e2f

first challenge try

Browse files
Files changed (2) hide show
  1. app.py +14 -12
  2. requirements.txt +17 -1
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,14 +11,7 @@ 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,14 +34,14 @@ 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
47
  # In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
48
- agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
49
- print(agent_code)
50
-
51
  # 2. Fetch Questions
52
  print(f"Fetching questions from: {questions_url}")
53
  try:
@@ -76,10 +70,18 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
76
  for item in questions_data:
77
  task_id = item.get("task_id")
78
  question_text = item.get("question")
 
79
  if not task_id or question_text is None:
80
  print(f"Skipping item with missing task_id or question: {item}")
81
  continue
82
  try:
 
 
 
 
 
 
 
83
  submitted_answer = agent(question_text)
84
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
85
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from agent import LangGraphAgent
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
 
11
 
12
  # --- Basic Agent Definition ---
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
+
 
 
 
 
 
 
 
15
 
16
  def run_and_submit_all( profile: gr.OAuthProfile | None):
17
  """
 
34
 
35
  # 1. Instantiate Agent ( modify this part to create your agent)
36
  try:
37
+ agent = LangGraphAgent()
38
  except Exception as e:
39
  print(f"Error instantiating agent: {e}")
40
  return f"Error initializing agent: {e}", None
41
  # In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
42
+ #agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
43
+ #print(agent_code)
44
+ agent_code = ""
45
  # 2. Fetch Questions
46
  print(f"Fetching questions from: {questions_url}")
47
  try:
 
70
  for item in questions_data:
71
  task_id = item.get("task_id")
72
  question_text = item.get("question")
73
+ file_name = item.get("file_name")
74
  if not task_id or question_text is None:
75
  print(f"Skipping item with missing task_id or question: {item}")
76
  continue
77
  try:
78
+ if file_name:
79
+ question_text += f"\n\nFile url: {api_url}/files/{task_id}"
80
+ try:
81
+ ext = file_name.split('.')[-1]
82
+ question_text += f"\n File extension is (.{ext} file)"
83
+ except:
84
+ pass
85
  submitted_answer = agent(question_text)
86
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
87
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
requirements.txt CHANGED
@@ -1,2 +1,18 @@
1
  gradio
2
- requests
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  gradio
2
+ requests
3
+ langchain
4
+ langchain-community
5
+ langchain-core
6
+ langchain-google-genai
7
+ langchain-huggingface
8
+ langchain-groq
9
+ langchain-tavily
10
+ langchain-chroma
11
+ langgraph
12
+ huggingface_hub
13
+ supabase
14
+ arxiv
15
+ pymupdf
16
+ wikipedia
17
+ pgvector
18
+ python-dotenv