euracle commited on
Commit
7ae835e
·
verified ·
1 Parent(s): 3d9cf23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -49,10 +49,6 @@ def initialize_vector_db():
49
  # System instructions for the LLM
50
  system_prompt = """You are an expert Agro-Homeopathy doctor. When providing remedies:
51
  1. Always specify medicine potency as 6c unless the uploaded text mentions some other value explicitly
52
- 2. Request detailed information about:
53
- - Plant symptoms
54
- - Weather conditions
55
- - Temperature
56
  3. Provide comprehensive diagnosis and treatment plans
57
  4. Base recommendations on homeopathic principles
58
  """
@@ -121,11 +117,19 @@ print(f"Loading and processing PDFs & vector database took {end_time - start_tim
121
  start_time = time.time()
122
  retriever = vector_db.as_retriever()
123
 
124
- prompt_template = """Use the following pieces of context to answer the question at the end. If the context doesn't provide enough information to answer the question, use your existing knowledge as an Agro-Homeopathy expert to provide the best possible answer. But remember to always mention the potency of the medicine. If you don't have that information, then mention the default value as 6c.
125
 
126
- {context}
127
 
128
  Question: {question}
 
 
 
 
 
 
 
 
129
  Answer:"""
130
 
131
  # Create the QA chain with correct variables
@@ -142,10 +146,17 @@ qa = RetrievalQA.from_chain_type(
142
  )
143
 
144
  # Create a separate LLMChain for fallback
145
- fallback_template = """You are an expert Agro-Homeopathy doctor. Remember to always mention the potency of the suggested medicine. If you don't have that information, then mention the default value as 6c. Answer the following question to the best of your ability:
146
 
147
  Question: {question}
148
 
 
 
 
 
 
 
 
149
  Answer:"""
150
 
151
  fallback_prompt = PromptTemplate(template=fallback_template, input_variables=["question"])
 
49
  # System instructions for the LLM
50
  system_prompt = """You are an expert Agro-Homeopathy doctor. When providing remedies:
51
  1. Always specify medicine potency as 6c unless the uploaded text mentions some other value explicitly
 
 
 
 
52
  3. Provide comprehensive diagnosis and treatment plans
53
  4. Base recommendations on homeopathic principles
54
  """
 
117
  start_time = time.time()
118
  retriever = vector_db.as_retriever()
119
 
120
+ prompt_template = """You are an expert Agro-Homeopathy doctor. Analyze the following context and question to provide a clear, structured response.
121
 
122
+ Context: {context}
123
 
124
  Question: {question}
125
+
126
+ Provide your response in the following format:
127
+ 1. Diagnosis: Analyze the plant symptoms and conditions described
128
+ 2. Treatment: Recommend specific homeopathic medicine(s) with exact potency
129
+ 3. Guidelines: List 3 key recommendations for addressing the issue
130
+
131
+ Remember to maintain a professional, clear tone and ensure all medicine recommendations include specific potency.
132
+
133
  Answer:"""
134
 
135
  # Create the QA chain with correct variables
 
146
  )
147
 
148
  # Create a separate LLMChain for fallback
149
+ fallback_template = """As an expert Agro-Homeopathy doctor, provide a structured response to the following question:
150
 
151
  Question: {question}
152
 
153
+ Format your response as follows:
154
+ 1. Diagnosis: Analyze the described plant condition
155
+ 2. Treatment: Recommend specific homeopathic medicine(s) with exact potency
156
+ 3. Guidelines: Provide 3 key recommendations
157
+
158
+ Maintain a professional tone and ensure all medicine recommendations include specific potency.
159
+
160
  Answer:"""
161
 
162
  fallback_prompt = PromptTemplate(template=fallback_template, input_variables=["question"])