Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,11 +25,11 @@ class BasicAgent:
|
|
| 25 |
|
| 26 |
def __call__(self, question: str) -> str:
|
| 27 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
|
|
|
| 28 |
messages = [HumanMessage(content=question)]
|
| 29 |
-
|
| 30 |
-
answer =
|
| 31 |
-
return answer
|
| 32 |
-
|
| 33 |
|
| 34 |
|
| 35 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
@@ -159,9 +159,11 @@ with gr.Blocks() as demo:
|
|
| 159 |
gr.Markdown(
|
| 160 |
"""
|
| 161 |
**Instructions:**
|
|
|
|
| 162 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
| 163 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
| 164 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
|
|
|
| 165 |
---
|
| 166 |
**Disclaimers:**
|
| 167 |
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).
|
|
|
|
| 25 |
|
| 26 |
def __call__(self, question: str) -> str:
|
| 27 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 28 |
+
# Wrap the question in a HumanMessage from langchain_core
|
| 29 |
messages = [HumanMessage(content=question)]
|
| 30 |
+
messages = self.graph.invoke({"messages": messages})
|
| 31 |
+
answer = messages['messages'][-1].content
|
| 32 |
+
return answer[14:]
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
|
| 159 |
gr.Markdown(
|
| 160 |
"""
|
| 161 |
**Instructions:**
|
| 162 |
+
|
| 163 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
| 164 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
| 165 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
| 166 |
+
|
| 167 |
---
|
| 168 |
**Disclaimers:**
|
| 169 |
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).
|