saritha commited on
Commit
620e520
·
verified ·
1 Parent(s): 581cdd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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
- #Gemini Response
44
  def get_response_llm(predicted_label, knowledge_base):
 
45
  prompt = (
46
- f"You're a helpful assistant who helps farmers understand sugarcane leaf diseases, "
47
- f"providing precautions, advice, and more. The predicted disease label is '{predicted_label}', "
48
- f"and additional information is provided from the knowledge base: {knowledge_base}. "
49
- f"Please provide a concise and beautiful response, using bold or bullet points where appropriate."
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*.