Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,10 +21,10 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 21 |
# --- Basic Agent Definition ---
|
| 22 |
|
| 23 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
# self.api_key = os.getenv("HF_TOKEN")
|
| 29 |
# self.llm = HuggingFaceInferenceAPI(
|
| 30 |
# model_name="deepseek-ai/DeepSeek-R1-0528",
|
|
@@ -38,33 +38,17 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 38 |
# llm=self.llm
|
| 39 |
# )
|
| 40 |
|
| 41 |
-
# async def run(self, question: str) -> str:
|
| 42 |
-
# print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 43 |
-
# answer = await self.agent.run(question)
|
| 44 |
-
# print(f"Agent returning answer: {answer}")
|
| 45 |
-
# return answer
|
| 46 |
-
|
| 47 |
-
# def __call__(self, question: str) -> str:
|
| 48 |
-
# #return asyncio.run(self.run(question))
|
| 49 |
-
# return self.run(question)
|
| 50 |
-
# #return self.agent.run(question)
|
| 51 |
-
|
| 52 |
-
class BasicAgent:
|
| 53 |
-
def __init__(self, agent):
|
| 54 |
-
self.agent = agent
|
| 55 |
-
print("✅ BasicAgent initialized successfully.")
|
| 56 |
-
|
| 57 |
async def run(self, question: str) -> str:
|
| 58 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 59 |
answer = await self.agent.run(question)
|
| 60 |
-
print(f"Agent returning answer: {answer
|
| 61 |
return answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
@classmethod
|
| 64 |
-
async def create(cls):
|
| 65 |
-
"""Factory method to asynchronously initialise BasicAgent."""
|
| 66 |
-
agent = await smart_agent()
|
| 67 |
-
return cls(agent)
|
| 68 |
|
| 69 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 70 |
"""
|
|
|
|
| 21 |
# --- Basic Agent Definition ---
|
| 22 |
|
| 23 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 24 |
+
class BasicAgent:
|
| 25 |
+
def __init__(self):
|
| 26 |
+
print("BasicAgent initialized. . . .")
|
| 27 |
+
self.agent = smart_agent()
|
| 28 |
# self.api_key = os.getenv("HF_TOKEN")
|
| 29 |
# self.llm = HuggingFaceInferenceAPI(
|
| 30 |
# model_name="deepseek-ai/DeepSeek-R1-0528",
|
|
|
|
| 38 |
# llm=self.llm
|
| 39 |
# )
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
async def run(self, question: str) -> str:
|
| 42 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 43 |
answer = await self.agent.run(question)
|
| 44 |
+
print(f"Agent returning answer: {answer}")
|
| 45 |
return answer
|
| 46 |
+
|
| 47 |
+
def __call__(self, question: str) -> str:
|
| 48 |
+
#return asyncio.run(self.run(question))
|
| 49 |
+
return self.run(question)
|
| 50 |
+
#return self.agent.run(question)
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 54 |
"""
|