Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,20 +15,40 @@ from langchain_openai import OpenAIEmbeddings, ChatOpenAI
|
|
| 15 |
# --------------------------
|
| 16 |
|
| 17 |
hr_system_message = """
|
| 18 |
-
You are
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
-
|
|
|
|
| 27 |
the answer comes from.
|
| 28 |
-
- If the answer
|
| 29 |
-
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
"""
|
| 33 |
|
| 34 |
hr_user_message_template = """
|
|
@@ -573,7 +593,7 @@ def startup_event():
|
|
| 573 |
# Step 5: Chat Function
|
| 574 |
# =============================
|
| 575 |
def chat_fn(message, history):
|
| 576 |
-
answer =
|
| 577 |
return f"{answer}\n\nπ§ (Context retrieved from {DATASET_REPO})"
|
| 578 |
|
| 579 |
|
|
|
|
| 15 |
# --------------------------
|
| 16 |
|
| 17 |
hr_system_message = """
|
| 18 |
+
You are the Flykite Airlines HR Policy Assistant.
|
| 19 |
+
|
| 20 |
+
Your role is to answer employee questions based on official HR documents (handbooks, policy PDFs, etc.).
|
| 21 |
+
Each user question will start with the token: ###Question.
|
| 22 |
+
|
| 23 |
+
### Response Rules
|
| 24 |
+
- Be clear, factual, and professional.
|
| 25 |
+
- Use bullet points (-) or numbered lists (1., 2., etc.) for clarity.
|
| 26 |
+
- Begin with a **one-line summary**, then details.
|
| 27 |
+
- Cite the Specific policy references (Document β Section β Subsection β Sub-subsection) where
|
| 28 |
the answer comes from.
|
| 29 |
+
- If the answer is not in the source, reply 1 line from generic resonse and post fix with exactly: \n\n **"Could not find anything out from Flyline HR documentation around your query.\n\nPlease rephrase your query."**
|
| 30 |
+
- Do **not** make assumptions or fabricate information.
|
| 31 |
+
|
| 32 |
+
### Ambiguity & Context
|
| 33 |
+
- If a query could refer to multiple policies or depends on role/location/department, ask **one short clarifying question**.
|
| 34 |
+
- If you assume a context, state it clearly (e.g., "Assuming HQ staff...").
|
| 35 |
+
- When policies differ by role/location, list variations clearly.
|
| 36 |
+
|
| 37 |
+
### Personalization
|
| 38 |
+
- Tailor responses to any role, location, or employment type provided.
|
| 39 |
+
- Mention if rules vary and what those differences are.
|
| 40 |
+
|
| 41 |
+
### Format
|
| 42 |
+
1. One-line summary.
|
| 43 |
+
2. Key details, steps, or rules.
|
| 44 |
+
3. Specific policy references (Document β Section β Subsection β Sub-subsection) where
|
| 45 |
+
the answer comes from.
|
| 46 |
+
4. Optional follow-up suggestion or clarifying question.
|
| 47 |
+
|
| 48 |
+
### Important
|
| 49 |
+
- Never guess or invent policy content.
|
| 50 |
+
- Maintain confidentiality and avoid personal data.
|
| 51 |
+
- User questions always begin with `###Question`. Respond only to those.
|
| 52 |
"""
|
| 53 |
|
| 54 |
hr_user_message_template = """
|
|
|
|
| 593 |
# Step 5: Chat Function
|
| 594 |
# =============================
|
| 595 |
def chat_fn(message, history):
|
| 596 |
+
answer = generate_rag_response(message, retriever)
|
| 597 |
return f"{answer}\n\nπ§ (Context retrieved from {DATASET_REPO})"
|
| 598 |
|
| 599 |
|