Spaces:
Running
Running
Rivalcoder
commited on
Commit
·
22c777f
1
Parent(s):
f791b03
Update Prompt
Browse files
llm.py
CHANGED
@@ -16,39 +16,36 @@ 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
|
20 |
|
21 |
🎯 GOAL:
|
22 |
-
-
|
23 |
-
-
|
24 |
-
-
|
25 |
-
-
|
26 |
|
27 |
📘 INSTRUCTIONS:
|
28 |
-
1.
|
29 |
-
2.
|
30 |
-
3.
|
31 |
-
4.
|
32 |
-
5.
|
33 |
-
6.
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
- "Most modern two-wheelers now offer tubeless tyre variants for better safety and convenience, but you should verify this with the specific model details."
|
40 |
-
- "No, you shouldn't use soft drinks like Thums Up as engine oil. Always use the recommended engine oil grade to avoid serious engine damage."
|
41 |
-
- "Sorry, I focus on insurance policy info — but here's a quick one: `Math.floor(Math.random() * 100) + 1` will give you a random number between 1 and 100 in JavaScript."
|
42 |
|
43 |
📤 RETURN FORMAT:
|
44 |
-
Respond in the
|
45 |
|
46 |
{{
|
47 |
-
|
48 |
"Answer to question 1",
|
49 |
"Answer to question 2",
|
50 |
...
|
51 |
-
|
52 |
}}
|
53 |
|
54 |
📚 CONTEXT:
|
@@ -57,9 +54,11 @@ Respond in the **exact JSON format** below — no extra text or explanations.
|
|
57 |
❓ QUESTIONS:
|
58 |
{questions_text}
|
59 |
|
60 |
-
Your task:
|
61 |
"""
|
62 |
-
|
|
|
|
|
63 |
model = genai.GenerativeModel('gemini-2.5-flash-lite')
|
64 |
response = model.generate_content(prompt)
|
65 |
response_text = response.text.strip()
|
|
|
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": [
|
45 |
"Answer to question 1",
|
46 |
"Answer to question 2",
|
47 |
...
|
48 |
+
]
|
49 |
}}
|
50 |
|
51 |
📚 CONTEXT:
|
|
|
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)
|
64 |
response_text = response.text.strip()
|