Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,13 +40,14 @@ transform = transforms.Compose([
|
|
40 |
# Load the class names (disease types)
|
41 |
class_names = ['BacterialBlights', 'Healthy', 'Mosaic', 'RedRot', 'Rust', 'Yellow']
|
42 |
|
43 |
-
#
|
44 |
def get_response_llm(predicted_label, knowledge_base):
|
|
|
45 |
prompt = (
|
46 |
-
f"You're a helpful assistant who helps farmers
|
47 |
-
f"
|
48 |
-
f"
|
49 |
-
f"Please provide a
|
50 |
)
|
51 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
52 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
@@ -54,7 +55,6 @@ def get_response_llm(predicted_label, knowledge_base):
|
|
54 |
return response.text
|
55 |
|
56 |
|
57 |
-
|
58 |
# Comprehensive knowledge base for sugarcane diseases and practices
|
59 |
knowledge_base = """
|
60 |
'BacterialBlights': Bacterial blights are caused by *Xanthomonas albilineans*.
|
|
|
40 |
# Load the class names (disease types)
|
41 |
class_names = ['BacterialBlights', 'Healthy', 'Mosaic', 'RedRot', 'Rust', 'Yellow']
|
42 |
|
43 |
+
# Updated function to avoid backslash issues
|
44 |
def get_response_llm(predicted_label, knowledge_base):
|
45 |
+
# Break down the prompt without unintended escape characters
|
46 |
prompt = (
|
47 |
+
f"You're a helpful assistant who helps farmers know about sugarcane diseases. "
|
48 |
+
f"Predicted disease label: '{predicted_label}'. "
|
49 |
+
f"Here is some additional knowledge: {knowledge_base}. "
|
50 |
+
f"Please provide a detailed response including advice, symptoms, and precautions."
|
51 |
)
|
52 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
53 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
|
|
55 |
return response.text
|
56 |
|
57 |
|
|
|
58 |
# Comprehensive knowledge base for sugarcane diseases and practices
|
59 |
knowledge_base = """
|
60 |
'BacterialBlights': Bacterial blights are caused by *Xanthomonas albilineans*.
|