Spaces:
Sleeping
Sleeping
reverse
Browse files- nova_agent.py +6 -22
nova_agent.py
CHANGED
|
@@ -190,31 +190,14 @@ If you cannot access the video content, try to do a search for a video with this
|
|
| 190 |
return "Unable to analyze Excel data. Please provide the file directly."
|
| 191 |
|
| 192 |
async def _handle_text_question(self, question: str) -> str:
|
| 193 |
-
"""Handle regular text-based questions
|
| 194 |
-
#
|
| 195 |
-
|
| 196 |
-
'libretext' in question.lower() or 'ck-12' in question.lower() or 'chemistry' in question.lower() or 'surname' in question.lower()
|
| 197 |
-
):
|
| 198 |
-
# Retrieval-augmented prompt (placeholder for retrieval step)
|
| 199 |
-
retrieval_context = "[RETRIEVED PASSAGES FROM CHEMISTRY MATERIALS WOULD GO HERE]"
|
| 200 |
-
prompt = f"""Use the following context to answer the question. If the answer is not in the context, say 'Not found in provided materials.'
|
| 201 |
-
Context:
|
| 202 |
-
{retrieval_context}
|
| 203 |
|
| 204 |
Question: {question}
|
|
|
|
| 205 |
Answer:"""
|
| 206 |
-
|
| 207 |
-
elif (
|
| 208 |
-
'vegetable' in question.lower() and 'botany' in question.lower()
|
| 209 |
-
):
|
| 210 |
-
botanical_definition = (
|
| 211 |
-
"In botany, a vegetable is any edible part of a plant that is not a fruit or seed. "
|
| 212 |
-
"Fruits contain seeds and develop from the ovary of a flower. Please use this definition."
|
| 213 |
-
)
|
| 214 |
-
prompt = f"{botanical_definition}\n\n{question}\n\nList only the vegetables, alphabetized, comma separated."
|
| 215 |
-
else:
|
| 216 |
-
# Default concise answer prompt
|
| 217 |
-
prompt = f"""Answer this question directly and concisely. Provide only the essential information requested, not explanations or step-by-step reasoning unless specifically asked.\n\nQuestion: {question}\n\nAnswer:"""
|
| 218 |
# Prepare the request payload for Nova Pro
|
| 219 |
payload = {
|
| 220 |
"messages": [
|
|
@@ -230,6 +213,7 @@ Answer:"""
|
|
| 230 |
"temperature": 0.0
|
| 231 |
}
|
| 232 |
}
|
|
|
|
| 233 |
# Call Nova Pro model
|
| 234 |
response = self.bedrock_client.invoke_model(
|
| 235 |
modelId=self.model_id,
|
|
|
|
| 190 |
return "Unable to analyze Excel data. Please provide the file directly."
|
| 191 |
|
| 192 |
async def _handle_text_question(self, question: str) -> str:
|
| 193 |
+
"""Handle regular text-based questions"""
|
| 194 |
+
# Create a more focused prompt for concise answers
|
| 195 |
+
prompt = f"""Answer this question directly and concisely. Provide only the essential information requested, not explanations or step-by-step reasoning unless specifically asked.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
Question: {question}
|
| 198 |
+
|
| 199 |
Answer:"""
|
| 200 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
# Prepare the request payload for Nova Pro
|
| 202 |
payload = {
|
| 203 |
"messages": [
|
|
|
|
| 213 |
"temperature": 0.0
|
| 214 |
}
|
| 215 |
}
|
| 216 |
+
|
| 217 |
# Call Nova Pro model
|
| 218 |
response = self.bedrock_client.invoke_model(
|
| 219 |
modelId=self.model_id,
|