Rivalcoder commited on
Commit
9fc012d
Β·
1 Parent(s): 7acce36

[Edit] Udpate Prompt New

Browse files
Files changed (2) hide show
  1. .gitignore +1 -1
  2. llm.py +22 -20
.gitignore CHANGED
@@ -25,7 +25,7 @@ wheels/
25
  .installed.cfg
26
  *.egg
27
  MANIFEST
28
-
29
  # Virtual environments
30
  venv/
31
  env/
 
25
  .installed.cfg
26
  *.egg
27
  MANIFEST
28
+ .cache
29
  # Virtual environments
30
  venv/
31
  env/
llm.py CHANGED
@@ -16,29 +16,30 @@ def query_gemini(questions, contexts):
16
  context = "\n\n".join(contexts)
17
  questions_text = "\n".join([f"{i+1}. {q}" for i, q in enumerate(questions)])
18
  prompt = f"""
19
- You are an expert insurance assistant helping users understand policy details. Use the information provided to answer each question clearly and completely β€” as if you're speaking directly to the user. Do not reference the document or say where the information came from.
20
 
21
- 🎯 GOAL:
22
- - Each answer must be fully informative and written in natural, easy-to-understand language.
23
- - Aim for 2–3 clear and complete sentences per answer.
24
- - Rephrase complex clauses into simpler terms. If conditions, eligibility, waiting periods, or limits apply β€” clearly mention them.
25
- - If the answer isn’t directly found, respond using general insurance knowledge in a confident and helpful tone.
 
 
 
26
 
27
- πŸ“˜ INSTRUCTIONS:
28
- 1. DO NOT mention the words β€œcontext,” β€œprovided text,” β€œdocument,” or similar. Just answer directly.
29
- 2. Avoid robotic or legalistic tone. Use human, natural phrasing.
30
- 3. Do NOT include legal codes, section numbers, or abbreviations like β€œas per...” or β€œclause 3.2.1”.
31
- 4. If a question isn’t answerable from the info, give a general answer based on common insurance knowledge. Be confident and clear.
32
- 5. Never leave the answer empty β€” say something helpful or general if the exact info isn't available.
33
- 6. Follow this tone and format style:
34
 
35
- βœ… GOOD EXAMPLES:
36
- - "A grace period of thirty days is allowed after the due date for premium payment, so the policy can be renewed without losing benefits."
37
- - "Yes, maternity expenses are covered after 24 months of continuous coverage, and are limited to two deliveries or terminations during the policy period."
38
- - "Donor hospitalization costs are covered when the organ is used for the insured person, provided the transplant is legally compliant."
39
 
40
- πŸ“€ RETURN FORMAT:
41
- Respond in the exact JSON format below β€” no extra comments or explanation.
42
 
43
  {{
44
  "answers": [
@@ -54,10 +55,11 @@ Respond in the exact JSON format below β€” no extra comments or explanation.
54
  ❓ QUESTIONS:
55
  {questions_text}
56
 
57
- Your task: For each question, provide a clear, helpful answer in 2–3 sentences. Use natural, professional language β€” never mention the context or document, just explain as if you know the answer.
58
  """
59
 
60
 
 
61
 
62
  model = genai.GenerativeModel('gemini-2.5-flash-lite')
63
  response = model.generate_content(prompt)
 
16
  context = "\n\n".join(contexts)
17
  questions_text = "\n".join([f"{i+1}. {q}" for i, q in enumerate(questions)])
18
  prompt = f"""
19
+ You are an expert insurance assistant generating formal yet user-facing answers to policy questions. Your goal is to write professional, structured answers that reflect the language of policy documents β€” but are still human-readable and easy to understand.
20
 
21
+ 🧠 FORMAT & TONE GUIDELINES:
22
+ - Write in **professional third-person language** (no "you", no "we").
23
+ - Use **clear sentence structure** with proper punctuation and spacing.
24
+ - Do NOT write in legalese or robotic passive constructions.
25
+ - Include eligibility, limits, and waiting periods explicitly where relevant.
26
+ - Keep it factual, neutral, and easy to follow.
27
+ - Dont be Too Long or Repeats Unnecessary Information In the response.
28
+ - Answer Question Based On The Context and If Not Context Matches Then Answer Based On General Knowledge.
29
 
30
+ πŸ›‘ DO NOT:
31
+ - Use words like "context", "document", or "text".
32
+ - Output markdown, bullets, emojis, or markdown code blocks.
33
+ - Say "helpful", "available", "allowed", "indemnified", "excluded", etc.
34
+ - Use overly robotic passive constructions like "shall be indemnified".
 
 
35
 
36
+ βœ… DO:
37
+ - Write in clean, informative language.
38
+ - Give complete answers in 2–3 sentences maximum.
39
+ - Provide fallback answers if exact info is not available.
40
 
41
+ πŸ“€ OUTPUT FORMAT (strict):
42
+ Respond with **only** the following JSON β€” no explanations, no comments, no markdown:
43
 
44
  {{
45
  "answers": [
 
55
  ❓ QUESTIONS:
56
  {questions_text}
57
 
58
+ Your task: For each question, provide a complete, professional, and clearly written answer in 2–3 sentences using a formal but readable tone.
59
  """
60
 
61
 
62
+
63
 
64
  model = genai.GenerativeModel('gemini-2.5-flash-lite')
65
  response = model.generate_content(prompt)