Spaces:
Sleeping
Sleeping
Commit
·
064a8a4
1
Parent(s):
5a3850e
Use simple prompt format
Browse files
app.py
CHANGED
|
@@ -74,35 +74,29 @@ class ResearchParrot:
|
|
| 74 |
|
| 75 |
context = "\n\n".join([doc.page_content for doc in docs])
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
2. Be technical, detailed, and thorough in your explanations.
|
| 85 |
-
3. If mathematical formulas or equations appear in the context, include them using LaTeX format ($...$ for inline, $$...$$ for blocks).
|
| 86 |
-
4. Highlight attack techniques, payloads, algorithms, and code snippets from the context.
|
| 87 |
-
5. If the context contains relevant information, use it to give a comprehensive answer.
|
| 88 |
-
6. Only say you don't have information if the context truly has nothing related to the question."""
|
| 89 |
-
},
|
| 90 |
-
{
|
| 91 |
-
"role": "user",
|
| 92 |
-
"content": f"""Here is context from research papers:
|
| 93 |
|
|
|
|
| 94 |
{context}
|
| 95 |
|
| 96 |
Question: {question}
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
]
|
| 101 |
|
| 102 |
response = self.client.chat_completion(
|
| 103 |
messages=messages,
|
| 104 |
model=self.model_id,
|
| 105 |
-
max_tokens=
|
| 106 |
temperature=0.3,
|
| 107 |
)
|
| 108 |
return response.choices[0].message.content
|
|
|
|
| 74 |
|
| 75 |
context = "\n\n".join([doc.page_content for doc in docs])
|
| 76 |
|
| 77 |
+
prompt = f"""You are a research assistant. Answer the question ONLY based on the provided context.
|
| 78 |
+
|
| 79 |
+
IMPORTANT RULES:
|
| 80 |
+
- Only use information from the context below and Make a Step by Step approach.
|
| 81 |
+
- If the context doesn't contain enough information to answer, say "I don't have enough information in the documents to answer this question."
|
| 82 |
+
- Always make it more technical in depth as much as you can because your readers are security researchers not normal people.
|
| 83 |
+
- Always highlight the attack technique, payload, math formula properly if available.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
Context:
|
| 86 |
{context}
|
| 87 |
|
| 88 |
Question: {question}
|
| 89 |
|
| 90 |
+
Answer:"""
|
| 91 |
+
|
| 92 |
+
messages = [
|
| 93 |
+
{"role": "user", "content": prompt}
|
| 94 |
]
|
| 95 |
|
| 96 |
response = self.client.chat_completion(
|
| 97 |
messages=messages,
|
| 98 |
model=self.model_id,
|
| 99 |
+
max_tokens=2048,
|
| 100 |
temperature=0.3,
|
| 101 |
)
|
| 102 |
return response.choices[0].message.content
|