Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,52 @@ from langchain_openai import ChatOpenAI
|
|
| 14 |
import spacy
|
| 15 |
import json
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# =========================================================
|
| 18 |
# Step 1: Download Vectorstore from Hugging Face Dataset
|
| 19 |
# =========================================================
|
|
|
|
| 14 |
import spacy
|
| 15 |
import json
|
| 16 |
|
| 17 |
+
#--===============================
|
| 18 |
+
# Define Prompt
|
| 19 |
+
#--===============================
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# Define the system message for Flykite Airlines HR Policy Assistant
|
| 23 |
+
# --- Refined System Prompt ---
|
| 24 |
+
QNA_SYSTEM_MESSAGE = """
|
| 25 |
+
You are the Flykite Airlines HR Policy Assistant.
|
| 26 |
+
|
| 27 |
+
Your role is to answer employee questions based on official HR documents (handbooks, policy PDFs, etc.).
|
| 28 |
+
Each user question will start with the token: ###Question.
|
| 29 |
+
|
| 30 |
+
### Response Rules
|
| 31 |
+
- Be clear, factual, and professional.
|
| 32 |
+
- Use bullet points (-) or numbered lists (1., 2., etc.) for clarity.
|
| 33 |
+
- Begin with a **one-line summary**, then details.
|
| 34 |
+
- Cite the Specific policy references (Document β Section β Subsection β Sub-subsection) where
|
| 35 |
+
the answer comes from.
|
| 36 |
+
- If the answer is not in the source, reply exactly: **"I don't know."**
|
| 37 |
+
- Do **not** make assumptions or fabricate information.
|
| 38 |
+
|
| 39 |
+
### Ambiguity & Context
|
| 40 |
+
- If a query could refer to multiple policies or depends on role/location/department, ask **one short clarifying question**.
|
| 41 |
+
- If you assume a context, state it clearly (e.g., "Assuming HQ staff...").
|
| 42 |
+
- When policies differ by role/location, list variations clearly.
|
| 43 |
+
|
| 44 |
+
### Personalization
|
| 45 |
+
- Tailor responses to any role, location, or employment type provided.
|
| 46 |
+
- Mention if rules vary and what those differences are.
|
| 47 |
+
|
| 48 |
+
### Format
|
| 49 |
+
1. One-line summary.
|
| 50 |
+
2. Key details, steps, or rules.
|
| 51 |
+
3. Specific policy references (Document β Section β Subsection β Sub-subsection) where
|
| 52 |
+
the answer comes from.
|
| 53 |
+
4. Optional follow-up suggestion or clarifying question.
|
| 54 |
+
|
| 55 |
+
### Important
|
| 56 |
+
- Never guess or invent policy content.
|
| 57 |
+
- Maintain confidentiality and avoid personal data.
|
| 58 |
+
- User questions always begin with `###Question`. Respond only to those.
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
# =========================================================
|
| 64 |
# Step 1: Download Vectorstore from Hugging Face Dataset
|
| 65 |
# =========================================================
|