Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -142,32 +142,33 @@ class CodeAgent:
|
|
| 142 |
)
|
| 143 |
|
| 144 |
def create_prompt(self, question: str, search_results: Optional[List[Dict[str, str]]] = None) -> str:
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
| 171 |
|
| 172 |
|
| 173 |
|
|
|
|
| 142 |
)
|
| 143 |
|
| 144 |
def create_prompt(self, question: str, search_results: Optional[List[Dict[str, str]]] = None) -> str:
|
| 145 |
+
prompt = []
|
| 146 |
+
|
| 147 |
+
if search_results:
|
| 148 |
+
prompt.append("Search Results:\n")
|
| 149 |
+
for i, sr in enumerate(search_results, 1):
|
| 150 |
+
snippet = sr.get("snippet", "")
|
| 151 |
+
title = sr.get("title", "")
|
| 152 |
+
prompt.append(f"[{i}] Title: {title}\nSnippet: {snippet}\n")
|
| 153 |
+
prompt.append("\n")
|
| 154 |
+
|
| 155 |
+
prompt.append(
|
| 156 |
+
"Instructions:\n"
|
| 157 |
+
"- ONLY answer with the exact fact, number, name, or list from above search results. NO explanations, NO restating question.\n"
|
| 158 |
+
"- If several possible answers, pick the most obvious or first. Use comma for lists.\n"
|
| 159 |
+
"- Only use 'Unknown' if absolutely impossible to answer from the search results or common knowledge.\n"
|
| 160 |
+
"- If the answer needs audio/image/code execution, reply: Unknown.\n"
|
| 161 |
+
"\n"
|
| 162 |
+
)
|
| 163 |
+
else:
|
| 164 |
+
prompt.append(
|
| 165 |
+
"No search results. Use your knowledge. If impossible, reply: Unknown\n"
|
| 166 |
+
)
|
| 167 |
|
| 168 |
+
prompt.append(f"Question: {question}\n")
|
| 169 |
+
prompt.append("Answer: ")
|
| 170 |
+
return "".join(prompt)
|
| 171 |
+
|
| 172 |
|
| 173 |
|
| 174 |
|