Spaces:
Runtime error
Runtime error
Test app fetching questions
Browse files
agent.py
CHANGED
|
@@ -23,8 +23,8 @@ from supabase import create_client, Client
|
|
| 23 |
|
| 24 |
load_dotenv()
|
| 25 |
|
| 26 |
-
os.environ["TAVILY_API_KEY"] = os.environ.get("TAVILY_API_KEY")
|
| 27 |
-
os.environ["GOOGLE_API_KEY"] = os.environ.get("GOOGLE_API_KEY")
|
| 28 |
|
| 29 |
__embeddings = HuggingFaceEmbeddings(
|
| 30 |
model_name="sentence-transformers/all-mpnet-base-v2",
|
|
@@ -207,8 +207,8 @@ def build_graph():
|
|
| 207 |
|
| 208 |
# Test
|
| 209 |
if __name__ == "__main__":
|
| 210 |
-
|
| 211 |
-
question = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
|
| 212 |
graph = build_graph()
|
| 213 |
messages = [HumanMessage(content=question)]
|
| 214 |
messages = graph.invoke({ "messages": messages })
|
|
|
|
| 23 |
|
| 24 |
load_dotenv()
|
| 25 |
|
| 26 |
+
# os.environ["TAVILY_API_KEY"] = os.environ.get("TAVILY_API_KEY")
|
| 27 |
+
# os.environ["GOOGLE_API_KEY"] = os.environ.get("GOOGLE_API_KEY")
|
| 28 |
|
| 29 |
__embeddings = HuggingFaceEmbeddings(
|
| 30 |
model_name="sentence-transformers/all-mpnet-base-v2",
|
|
|
|
| 207 |
|
| 208 |
# Test
|
| 209 |
if __name__ == "__main__":
|
| 210 |
+
question = "When was a picture of St. Thomas Aquinas first added to the Wikipedia page on the Principle of double effect?"
|
| 211 |
+
# question = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
|
| 212 |
graph = build_graph()
|
| 213 |
messages = [HumanMessage(content=question)]
|
| 214 |
messages = graph.invoke({ "messages": messages })
|
app.py
CHANGED
|
@@ -3,8 +3,6 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
from langchain_core.messages import HumanMessage
|
| 7 |
-
from agent import build_graph
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
@@ -14,17 +12,12 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 14 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
-
self.graph = build_graph()
|
| 18 |
print("BasicAgent initialized.")
|
| 19 |
def __call__(self, question: str) -> str:
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
answer
|
| 23 |
-
|
| 24 |
-
# print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 25 |
-
# fixed_answer = "This is a default answer."
|
| 26 |
-
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 27 |
-
return answer[14:]
|
| 28 |
|
| 29 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 30 |
"""
|
|
@@ -153,11 +146,9 @@ with gr.Blocks() as demo:
|
|
| 153 |
gr.Markdown(
|
| 154 |
"""
|
| 155 |
**Instructions:**
|
| 156 |
-
|
| 157 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
| 158 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
| 159 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
| 160 |
-
|
| 161 |
---
|
| 162 |
**Disclaimers:**
|
| 163 |
Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
|
|
|
| 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 |
"""
|
|
|
|
| 146 |
gr.Markdown(
|
| 147 |
"""
|
| 148 |
**Instructions:**
|
|
|
|
| 149 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
| 150 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
| 151 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
|
|
|
| 152 |
---
|
| 153 |
**Disclaimers:**
|
| 154 |
Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
|