doxiy commited on
Commit
9d54a2c
·
1 Parent(s): 9ff713c

version complète v03

Browse files
Files changed (2) hide show
  1. agent.py +0 -1
  2. gaia_submit.py +10 -3
agent.py CHANGED
@@ -1,4 +1,3 @@
1
- import gradio as gr
2
  from llama_index.llms.openai import OpenAI
3
  from llama_index.agent.openai import OpenAIAgent
4
  from tools import TOOLS
 
 
1
  from llama_index.llms.openai import OpenAI
2
  from llama_index.agent.openai import OpenAIAgent
3
  from tools import TOOLS
gaia_submit.py CHANGED
@@ -1,7 +1,11 @@
 
1
  import requests
2
  from pydantic import BaseModel
3
  from agent import run_agent
4
 
 
 
 
5
 
6
  #structure attendu
7
  class Question(BaseModel):
@@ -16,10 +20,13 @@ class Answer(BaseModel):
16
  def answer_question(question:str) -> str:
17
  return str(run_agent(question)).strip()
18
 
 
 
 
19
 
20
  def run_agent_on_all_questions():
21
  #1. Obtenir les question
22
- response = requests.get("https://gaia-course-api.spaces.huggingface.tech/questions")
23
  questions = response.json()
24
 
25
  answers = []
@@ -37,12 +44,12 @@ def run_agent_on_all_questions():
37
  #2. envoi de la reponse
38
  payload = {
39
  "username": "Doxiy",
40
- "agent_code": "https://huggingface.co/spaces/doxiy/exam-agent/tree/main",
41
  "answers": answers
42
  }
43
 
44
 
45
- r = requests.post("https://gaia-course-api.spaces.huggingface.tech/submit", json=payload)
46
  if r.status_code == 200:
47
  logs += "\n✅ Envoi avec succes. Resultat:\n" + str(r.json())
48
  else:
 
1
+ import os
2
  import requests
3
  from pydantic import BaseModel
4
  from agent import run_agent
5
 
6
+ # Récupération automatique de l’URL du repo (via SPACE_ID)
7
+ space_id = os.getenv("SPACE_ID", "doxiy/exam-agent") # Valeur par défaut si non dans un Space
8
+ agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
9
 
10
  #structure attendu
11
  class Question(BaseModel):
 
20
  def answer_question(question:str) -> str:
21
  return str(run_agent(question)).strip()
22
 
23
+ BASE_URL = "https://agents-course-unit4-scoring.hf.space"
24
+ questions_url = f"{BASE_URL}/questions"
25
+ submit_url = f"{BASE_URL}/submit"
26
 
27
  def run_agent_on_all_questions():
28
  #1. Obtenir les question
29
+ response = requests.get(questions_url)
30
  questions = response.json()
31
 
32
  answers = []
 
44
  #2. envoi de la reponse
45
  payload = {
46
  "username": "Doxiy",
47
+ "agent_code": agent_code,
48
  "answers": answers
49
  }
50
 
51
 
52
+ r = requests.post(submit_url, json=payload)
53
  if r.status_code == 200:
54
  logs += "\n✅ Envoi avec succes. Resultat:\n" + str(r.json())
55
  else: