Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,7 +63,7 @@ async def lifespan(app: FastAPI):
|
|
| 63 |
# Load models into the shared dictionary
|
| 64 |
ml_models["embedder"] = HuggingFaceEmbeddings(
|
| 65 |
model_name="BAAI/bge-base-en-v1.5", #better but lil slower
|
| 66 |
-
# model_name="intfloat/e5-large-v2", #lil faster
|
| 67 |
encode_kwargs={
|
| 68 |
"batch_size": 64,
|
| 69 |
# "normalize_embeddings": True
|
|
@@ -81,28 +81,27 @@ async def lifespan(app: FastAPI):
|
|
| 81 |
max_output_tokens=300
|
| 82 |
)
|
| 83 |
ml_models["prompt_template"] = ChatPromptTemplate.from_template("""
|
| 84 |
-
**Role**: You are an expert decision
|
| 85 |
-
|
| 86 |
-
**
|
| 87 |
-
|
| 88 |
-
- Provide a **direct, complete, and accurate** answer.
|
| 89 |
-
- Do **not** mention document IDs, page numbers, or say "Based on the document..."
|
| 90 |
-
- Avoid bullet points. Respond in clear, well-formed sentences.
|
| 91 |
-
- If relevant, use the exact language from the policy clauses in a natural way.
|
| 92 |
|
| 93 |
-
|
| 94 |
|
| 95 |
-
**
|
| 96 |
-
{context}
|
| 97 |
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
|
| 103 |
-
|
|
|
|
| 104 |
|
| 105 |
-
|
|
|
|
| 106 |
"""
|
| 107 |
)
|
| 108 |
print("✅ Models and prompt loaded successfully!")
|
|
|
|
| 63 |
# Load models into the shared dictionary
|
| 64 |
ml_models["embedder"] = HuggingFaceEmbeddings(
|
| 65 |
model_name="BAAI/bge-base-en-v1.5", #better but lil slower
|
| 66 |
+
# model_name="intfloat/e5-large-v2", #lil faster but dont know response is slow
|
| 67 |
encode_kwargs={
|
| 68 |
"batch_size": 64,
|
| 69 |
# "normalize_embeddings": True
|
|
|
|
| 81 |
max_output_tokens=300
|
| 82 |
)
|
| 83 |
ml_models["prompt_template"] = ChatPromptTemplate.from_template("""
|
| 84 |
+
**Role**: You are an expert decision maker Assistant in the domain such as insurance, legal compliance, human resources, and contract management using ONLY the provided context.
|
| 85 |
+
Do not use your own knowledge.
|
| 86 |
+
**Context**:
|
| 87 |
+
{context}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
+
**Query**: {full_query}
|
| 90 |
|
| 91 |
+
**Response**:
|
|
|
|
| 92 |
|
| 93 |
+
Example how to answer for thr query:
|
| 94 |
+
1. query:What is the grace period for premium payment under the National Parivar Mediclaim Plus Policy?
|
| 95 |
+
response: A grace period of thirty days is provided for premium payment after the due date to renew or continue the policy without losing continuity benefits.
|
| 96 |
|
| 97 |
+
2. query: What is the waiting period for pre-existing diseases (PED) to be covered?
|
| 98 |
+
response: There is a waiting period of thirty-six (36) months of continuous coverage from the first policy inception for pre-existing diseases and their direct complications to be covered.
|
| 99 |
|
| 100 |
+
3. query: Are the medical expenses for an organ donor covered under this policy?
|
| 101 |
+
response : Yes, the policy indemnifies the medical expenses for the organ donor's hospitalization for the purpose of harvesting the organ, provided the organ is for an insured person and the donation complies with the Transplantation of Human Organs Act, 1994.
|
| 102 |
|
| 103 |
+
4. query: Does this policy cover maternity expenses, and what are the conditions?
|
| 104 |
+
response: Yes, the policy covers maternity expenses, including childbirth and lawful medical termination of pregnancy. To be eligible, the female insured person must have been continuously covered for at least 24 months. The benefit is limited to two deliveries or terminations during the policy period.
|
| 105 |
"""
|
| 106 |
)
|
| 107 |
print("✅ Models and prompt loaded successfully!")
|