Spaces:
Sleeping
Sleeping
updated agent
Browse files
app.py
CHANGED
|
@@ -12,26 +12,32 @@ 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("
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
def __call__(self, question: str) -> str:
|
| 21 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 22 |
|
| 23 |
-
promt = """
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
output = self.client.chat.completions.create(
|
| 27 |
messages= [
|
| 28 |
{"role":"User","content":question}
|
| 29 |
],
|
| 30 |
stream= False,
|
| 31 |
-
max_tokens=
|
| 32 |
extra_body={"thinking":{"type":'disabled'}}
|
| 33 |
)
|
| 34 |
-
return output.choices[0].message.content
|
| 35 |
|
| 36 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 37 |
"""
|
|
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
+
print("Srj's Agent initialized.")
|
| 16 |
+
self.client = InferenceClient(model= "moonshotai/Kimi-K2.5", token = os.environ.get("HF_TOKEN"))
|
| 17 |
+
|
|
|
|
|
|
|
| 18 |
def __call__(self, question: str) -> str:
|
| 19 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 20 |
|
| 21 |
+
promt = f"""Question: {question}
|
| 22 |
+
|
| 23 |
+
Solve step-by-step internally but respond with ONLY the final answer.
|
| 24 |
+
NO "Final Answer:", NO explanation, NO reasoning.
|
| 25 |
+
Just the exact answer string (number, city name, or short list).
|
| 26 |
+
|
| 27 |
+
Examples:
|
| 28 |
+
Capital of France? → Paris
|
| 29 |
+
2024 Olympics city? → Paris
|
| 30 |
+
15 × 3? → 45"""
|
| 31 |
+
|
| 32 |
output = self.client.chat.completions.create(
|
| 33 |
messages= [
|
| 34 |
{"role":"User","content":question}
|
| 35 |
],
|
| 36 |
stream= False,
|
| 37 |
+
max_tokens= 50,
|
| 38 |
extra_body={"thinking":{"type":'disabled'}}
|
| 39 |
)
|
| 40 |
+
return output.choices[0].message.content.strip()
|
| 41 |
|
| 42 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 43 |
"""
|