Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
|
@@ -12,11 +13,26 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 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
|
|
|
|
| 20 |
return fixed_answer
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from tools import *
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
|
|
|
| 13 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 14 |
class BasicAgent:
|
| 15 |
def __init__(self):
|
| 16 |
+
llm = HuggingFaceEndpoint(repo_id="Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 17 |
+
chat = ChatHuggingFace(llm=llm, verbose=True)
|
| 18 |
+
tools = [guest_info_tool]
|
| 19 |
+
chat_with_tools = chat.bind_tools(tools)
|
| 20 |
+
self.builder = StateGraph(AgentState)
|
| 21 |
+
self.builder.add_node("assistant", assistant)
|
| 22 |
+
self.builder.add_node("tools", ToolNode(tools))
|
| 23 |
+
self.builder.add_edge(START, "assistant")
|
| 24 |
+
self.builder.add_conditional_edges("assistant", tools_condition)
|
| 25 |
+
self.builder.add_edge("tools", "assistant")
|
| 26 |
+
self.builder.compile()
|
| 27 |
print("BasicAgent initialized.")
|
| 28 |
def __call__(self, question: str) -> str:
|
| 29 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 30 |
+
messages = [HumanMessage(content="Tell me about our guest named 'Lady Ada Lovelace'.")]
|
| 31 |
+
response = self.invoke({"messages": messages})
|
| 32 |
+
response['messages'][-1].content
|
| 33 |
fixed_answer = "This is a default answer."
|
| 34 |
+
print(f"Agent returning answer: {response}")
|
| 35 |
+
|
| 36 |
return fixed_answer
|
| 37 |
|
| 38 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|