Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,31 @@
|
|
1 |
-
""" Basic Agent Evaluation Runner"""
|
2 |
import os
|
3 |
-
import inspect
|
4 |
import gradio as gr
|
5 |
import requests
|
|
|
6 |
import pandas as pd
|
7 |
from langchain_core.messages import HumanMessage
|
8 |
from agents import create_agent_flow
|
9 |
|
10 |
-
|
11 |
-
|
12 |
# (Keep Constants as is)
|
13 |
# --- Constants ---
|
14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
15 |
|
16 |
# --- Basic Agent Definition ---
|
17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
18 |
-
|
19 |
-
|
20 |
class BasicAgent:
|
21 |
-
|
22 |
def __init__(self):
|
23 |
print("BasicAgent initialized.")
|
24 |
-
self.
|
25 |
-
|
26 |
def __call__(self, question: str) -> str:
|
27 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
36 |
"""
|
|
|
|
|
1 |
import os
|
|
|
2 |
import gradio as gr
|
3 |
import requests
|
4 |
+
import inspect
|
5 |
import pandas as pd
|
6 |
from langchain_core.messages import HumanMessage
|
7 |
from agents import create_agent_flow
|
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 |
class BasicAgent:
|
16 |
+
|
17 |
def __init__(self):
|
18 |
print("BasicAgent initialized.")
|
19 |
+
self.agent = create_agent_flow()
|
20 |
+
|
21 |
def __call__(self, question: str) -> str:
|
22 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
23 |
+
|
24 |
+
question = [HumanMessage(content=question)]
|
25 |
+
question_ask = self.graph.invoke({"messages": question})
|
26 |
+
response = question_ask['messages'][-1].content
|
27 |
+
print(f"Agent returning fixed answer: {response}")
|
28 |
+
return response[8:]
|
29 |
|
30 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
31 |
"""
|