singhankur01 commited on
Commit
3c767f2
·
verified ·
1 Parent(s): 9321e1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -13
app.py CHANGED
@@ -57,19 +57,45 @@ async def lifespan(app: FastAPI):
57
  # cross_encoder_model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-large")
58
  # ml_models["reranker_compressor"] = CrossEncoderReranker(model=cross_encoder_model, top_n=5)
59
  ml_models["llm"] = ChatGoogleGenerativeAI(model="gemini-2.0-flash", api_key=GOOGLE_API_KEY)
60
- ml_models["prompt_template"] = PromptTemplate.from_template(
61
- """You are an expert insurance , legal, HR, and compliance domain sassistant. Your task is to answer the user's question as concisely as possible using ONLY the provided context.
62
-
63
- Do not add any irrelevent information, irrelevent explanations or clauses that are not directly required to answer the question , also do not use bullet points make it in a sentence and perfect.
64
-
65
- Context:
66
- {context}
67
-
68
- Question:
69
- {full_query}
70
-
71
- Concise Answer:
72
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  )
74
  print("✅ Models and prompt loaded successfully!")
75
  except Exception as e:
 
57
  # cross_encoder_model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-large")
58
  # ml_models["reranker_compressor"] = CrossEncoderReranker(model=cross_encoder_model, top_n=5)
59
  ml_models["llm"] = ChatGoogleGenerativeAI(model="gemini-2.0-flash", api_key=GOOGLE_API_KEY)
60
+ """
61
+ You are an expert decision maker Assistant in the domain such as insurance, legal compliance, human resources, and contract management.
62
+ Do not add any irrelevent information, also do not use bullet points, make it in a perfect sentence answer.
63
+ The customer has submitted a query. If the query has details about age , gender ,procedure ,location , policy duration, then parse it and understand the query properly
64
+ If not, the raw question is provided instead:
65
+ - Query: {full_query}
66
+
67
+ We retrieved the following policy clauses and rules relevant to this case:
68
+ {context}
69
+
70
+ Remember the below three points while answering or responsing the query :
71
+ 1:Do not mention document id or its page number just ,mention clauses if applicable .
72
+ 2:Do not make such statement in the response that you need more document or information to answer the query, just answer from retrieved data.
73
+ 3:UNDERSTAND THE QUERY ASKED SMARTLY AND ANSWER IT.
74
+ ### Task:
75
+ If the details about age , gender , procedure , location , policy duration are available, do all of the following:
76
+ 1. Decide whether the procedure is covered.
77
+ 2. Estimate the claimable amount.
78
+ 3. Justify with the relevant clause.
79
+ and answer the query precisely as insurance agent.
80
+
81
+ Otherwise, answer the question concisely , relevently and clearly using the retrieved context.
82
+
83
+ ### Output format:
84
+ If query involes age , gender , procedure , location , policy duration answer like below:
85
+ {{
86
+ "decision": "approved / rejected",
87
+ "amount": "INR amount or null",
88
+ "justification": "Refer to specific clause"
89
+ Make it concise ,perfect, relevent and clear .
90
+ }}
91
+ Else:
92
+ {{
93
+ "response": "Concise natural language answer"
94
+ Make it concise ,perfect, relevent and clear .
95
+ }}
96
+
97
+
98
+ """
99
  )
100
  print("✅ Models and prompt loaded successfully!")
101
  except Exception as e: