Update main.py
Browse files
main.py
CHANGED
|
@@ -14,20 +14,17 @@ TYPEGPT_API_KEY = "sk-oPdaZC7n1JlDq0sJ5NSSyHe7sYaeAXeEuj0wX4Lk8hlOGPF8" # Replac
|
|
| 14 |
SEARCH_API_URL = "https://superapis-bing.hf.space/search"
|
| 15 |
|
| 16 |
# --- System Prompt ---
|
| 17 |
-
#
|
| 18 |
SYSTEM_PROMPT = """
|
| 19 |
You are an expert AI research assistant. Your primary goal is to provide accurate, comprehensive, and helpful answers based ONLY on the provided search results.
|
| 20 |
-
|
| 21 |
Instructions:
|
| 22 |
1. Carefully analyze the user's query and the provided search results.
|
| 23 |
2. Synthesize an answer directly from the information found in the search results.
|
| 24 |
-
3. For every statement or piece of information you provide, you MUST cite the corresponding search result
|
| 25 |
-
4.
|
| 26 |
-
5. If
|
| 27 |
-
6.
|
| 28 |
-
7.
|
| 29 |
-
8. Structure your response in a clear and easy-to-read format. Start with a direct answer, followed by a more detailed explanation.
|
| 30 |
-
9. At the end of your response, include a "## Sources" section and list all the source URLs you used.
|
| 31 |
"""
|
| 32 |
|
| 33 |
# --- Pydantic Models ---
|
|
@@ -63,7 +60,7 @@ class ChatCompletionStreamResponse(BaseModel):
|
|
| 63 |
app = FastAPI(
|
| 64 |
title="Perplexity-like API",
|
| 65 |
description="An API that uses web search to answer questions with citations, supporting streaming.",
|
| 66 |
-
version="2.
|
| 67 |
)
|
| 68 |
|
| 69 |
|
|
|
|
| 14 |
SEARCH_API_URL = "https://superapis-bing.hf.space/search"
|
| 15 |
|
| 16 |
# --- System Prompt ---
|
| 17 |
+
# This prompt guides the AI to behave like a factual research assistant.
|
| 18 |
SYSTEM_PROMPT = """
|
| 19 |
You are an expert AI research assistant. Your primary goal is to provide accurate, comprehensive, and helpful answers based ONLY on the provided search results.
|
|
|
|
| 20 |
Instructions:
|
| 21 |
1. Carefully analyze the user's query and the provided search results.
|
| 22 |
2. Synthesize an answer directly from the information found in the search results.
|
| 23 |
+
3. For every statement or piece of information you provide, you MUST cite the corresponding search result number in the format `[<number>]`.
|
| 24 |
+
4. If multiple sources support a statement, you can cite them like `[1, 2]`.
|
| 25 |
+
5. If the search results do not contain enough information to answer the query, you must explicitly state that you could not find the information in the provided context.
|
| 26 |
+
6. Do not use any prior knowledge or information outside of the provided search results.
|
| 27 |
+
7. Structure your response in a clear and easy-to-read format. Start with a direct answer, followed by a more detailed explanation.
|
|
|
|
|
|
|
| 28 |
"""
|
| 29 |
|
| 30 |
# --- Pydantic Models ---
|
|
|
|
| 60 |
app = FastAPI(
|
| 61 |
title="Perplexity-like API",
|
| 62 |
description="An API that uses web search to answer questions with citations, supporting streaming.",
|
| 63 |
+
version="2.0.0"
|
| 64 |
)
|
| 65 |
|
| 66 |
|