Spaces:
Sleeping
Sleeping
ready to start developing agent specifics
Browse files- agent.py +3 -4
- assignment_utils.py +25 -12
agent.py
CHANGED
|
@@ -3,8 +3,6 @@ from flow import createFlow
|
|
| 3 |
from logger import Logger
|
| 4 |
import config
|
| 5 |
|
| 6 |
-
from assignment_utils import getQuestionByPos
|
| 7 |
-
|
| 8 |
|
| 9 |
class Agent:
|
| 10 |
def __init__(self, logger):
|
|
@@ -18,9 +16,10 @@ class Agent:
|
|
| 18 |
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
|
|
|
| 21 |
logger = Logger(config.logLevel,config.logFile)
|
| 22 |
agent = Agent(logger)
|
| 23 |
question = getQuestionByPos(0)
|
| 24 |
print(question)
|
| 25 |
-
response = agent.invoke(question['question'])
|
| 26 |
-
print(response)
|
|
|
|
| 3 |
from logger import Logger
|
| 4 |
import config
|
| 5 |
|
|
|
|
|
|
|
| 6 |
|
| 7 |
class Agent:
|
| 8 |
def __init__(self, logger):
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
if __name__ == "__main__":
|
| 19 |
+
from assignment_utils import getQuestionByPos
|
| 20 |
logger = Logger(config.logLevel,config.logFile)
|
| 21 |
agent = Agent(logger)
|
| 22 |
question = getQuestionByPos(0)
|
| 23 |
print(question)
|
| 24 |
+
#response = agent.invoke(question['question'])
|
| 25 |
+
#print(response)
|
assignment_utils.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
import config
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def getQuestions():
|
|
@@ -27,25 +29,24 @@ def printQuestions():
|
|
| 27 |
print(f"{i+1} ({question['task_id']}): {question['question']} {'(File: ' + question['file_name'] + ')' if question['file_name'] else ''}")
|
| 28 |
|
| 29 |
def submitAnswers(answers):
|
| 30 |
-
|
| 31 |
"username": "jproman",
|
| 32 |
"agent_code": "https://huggingface.co/spaces/jproman/Final_Assignment_Template/tree/main",
|
| 33 |
"answers": answers
|
| 34 |
}
|
| 35 |
-
response = requests.post(config.submitUrl, json=
|
| 36 |
response.raise_for_status()
|
| 37 |
-
|
| 38 |
-
|
| 39 |
f"Submission Successful!\n"
|
| 40 |
-
f"User: {
|
| 41 |
-
f"Overall Score: {
|
| 42 |
-
f"({
|
| 43 |
-
f"Message: {
|
| 44 |
)
|
| 45 |
-
return
|
| 46 |
|
| 47 |
def getTestAnswers():
|
| 48 |
-
task_id = ""
|
| 49 |
return [
|
| 50 |
{"task_id": "8e867cd7-cff9-4e6c-867a-ff5ddc2550be", "submitted_answer": "test answer"},
|
| 51 |
{"task_id": "a1e91b78-d3d8-4675-bb8d-62741b4b68a6", "submitted_answer": "test answer"},
|
|
@@ -69,10 +70,22 @@ def getTestAnswers():
|
|
| 69 |
{"task_id": "5a0c1adf-205e-4841-a666-7c3ef95def9d", "submitted_answer": "test answer"},
|
| 70 |
]
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
if __name__ == "__main__":
|
| 73 |
# https://huggingface.co/spaces/agents-course/Students_leaderboard
|
| 74 |
questions = getQuestions()
|
| 75 |
printQuestions()
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
|
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
import config
|
| 5 |
+
from logger import Logger
|
| 6 |
+
from agent import Agent
|
| 7 |
|
| 8 |
|
| 9 |
def getQuestions():
|
|
|
|
| 29 |
print(f"{i+1} ({question['task_id']}): {question['question']} {'(File: ' + question['file_name'] + ')' if question['file_name'] else ''}")
|
| 30 |
|
| 31 |
def submitAnswers(answers):
|
| 32 |
+
submissionData = {
|
| 33 |
"username": "jproman",
|
| 34 |
"agent_code": "https://huggingface.co/spaces/jproman/Final_Assignment_Template/tree/main",
|
| 35 |
"answers": answers
|
| 36 |
}
|
| 37 |
+
response = requests.post(config.submitUrl, json=submissionData, timeout=60)
|
| 38 |
response.raise_for_status()
|
| 39 |
+
resultData = response.json()
|
| 40 |
+
finalStatus = (
|
| 41 |
f"Submission Successful!\n"
|
| 42 |
+
f"User: {resultData.get('username')}\n"
|
| 43 |
+
f"Overall Score: {resultData.get('score', 'N/A')}% "
|
| 44 |
+
f"({resultData.get('correct_count', '?')}/{resultData.get('total_attempted', '?')} correct)\n"
|
| 45 |
+
f"Message: {resultData.get('message', 'No message received.')}"
|
| 46 |
)
|
| 47 |
+
return finalStatus
|
| 48 |
|
| 49 |
def getTestAnswers():
|
|
|
|
| 50 |
return [
|
| 51 |
{"task_id": "8e867cd7-cff9-4e6c-867a-ff5ddc2550be", "submitted_answer": "test answer"},
|
| 52 |
{"task_id": "a1e91b78-d3d8-4675-bb8d-62741b4b68a6", "submitted_answer": "test answer"},
|
|
|
|
| 70 |
{"task_id": "5a0c1adf-205e-4841-a666-7c3ef95def9d", "submitted_answer": "test answer"},
|
| 71 |
]
|
| 72 |
|
| 73 |
+
def submitFirstAnswers(n):
|
| 74 |
+
questions = getQuestions()
|
| 75 |
+
answers = getTestAnswers()
|
| 76 |
+
logger = Logger(config.logLevel,config.logFile)
|
| 77 |
+
agent = Agent(logger)
|
| 78 |
+
for i in range(n):
|
| 79 |
+
response = agent.invoke(questions[i]['question'])
|
| 80 |
+
answers[i]["submitted_answer"] = response
|
| 81 |
+
finalStatus = submitAnswers(answers)
|
| 82 |
+
print(finalStatus)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
if __name__ == "__main__":
|
| 86 |
# https://huggingface.co/spaces/agents-course/Students_leaderboard
|
| 87 |
questions = getQuestions()
|
| 88 |
printQuestions()
|
| 89 |
+
response = submitAnswers(getTestAnswers())
|
| 90 |
+
print(response)
|
| 91 |
|