rkihacker commited on
Commit
c2074e1
·
verified ·
1 Parent(s): 56d44b2

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -10
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
- # UPDATED: This prompt now instructs the AI to use markdown links for citations.
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. **Format your citations as markdown links, like `[<number>](URL)`.** For example, a citation to the first source should look like `[1](https://example.com)`. Use the exact URL provided in the search result.
26
- 5. If multiple sources support a statement, you can list the citations together, like `[1](https://example.com), [2](https://another-example.com)`.
27
- 6. 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.
28
- 7. Do not use any prior knowledge or information outside of the provided search results.
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.1.0" # Version updated
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