Spaces:
Running
Running
Update app.py
Browse files
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 = """
|
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 = """
|
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"])
|