Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,12 +34,12 @@ class BasicAgent:
|
|
| 34 |
def __init__(self):
|
| 35 |
print("BasicAgent initialized.")
|
| 36 |
openaikey = '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'
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
model = InferenceClientModel(
|
| 45 |
model_id="gpt-4o",
|
|
@@ -57,9 +57,9 @@ class BasicAgent:
|
|
| 57 |
def __call__(self, question: str) -> str:
|
| 58 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 59 |
# Inject system prompt + question
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
answer = self.agent.run(question)
|
| 63 |
print(f"Agent returning answer: {answer.strip()}")
|
| 64 |
return answer.strip()
|
| 65 |
|
|
|
|
| 34 |
def __init__(self):
|
| 35 |
print("BasicAgent initialized.")
|
| 36 |
openaikey = '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'
|
| 37 |
+
self.system_message = (
|
| 38 |
+
"You are a question answering agent for scientific and encyclopedic questions. "
|
| 39 |
+
"Your goal is to provide concise, factually correct answers using only verified sources. "
|
| 40 |
+
"Always return a direct answer, no extra text or explanation. "
|
| 41 |
+
"If a question asks for a count, return only the number."
|
| 42 |
+
)
|
| 43 |
|
| 44 |
model = InferenceClientModel(
|
| 45 |
model_id="gpt-4o",
|
|
|
|
| 57 |
def __call__(self, question: str) -> str:
|
| 58 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 59 |
# Inject system prompt + question
|
| 60 |
+
question_with_prompt = f"{self.system_message}\n\n{question.strip()}"
|
| 61 |
+
answer = self.agent.run(question_with_prompt)
|
| 62 |
+
# answer = self.agent.run(question)
|
| 63 |
print(f"Agent returning answer: {answer.strip()}")
|
| 64 |
return answer.strip()
|
| 65 |
|