-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgeminiResponse.py
More file actions
29 lines (21 loc) · 1.01 KB
/
geminiResponse.py
File metadata and controls
29 lines (21 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
from google import genai
from dotenv import load_dotenv
load_dotenv()
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
client = genai.Client(api_key=GEMINI_API_KEY)
def get_instructions(plant_type, plant_age, disease):
prompt_healthy = f"""
A farmer has a {plant_type} plant age around {plant_age}, but it is healthy. Provide a simple step-by-step guide on how to maintain it.
Use clear and practical steps. First tell your plant is healthy.
"""
prompt = f"""
A farmer has a {plant_type} plant age around {plant_age}, affected by {disease} disease. Provide a simple step-by-step guide on how to treat it.
Use clear and practical steps.
"""
if disease == "Healthy":
response = client.models.generate_content(model="gemini-1.5-pro", contents=prompt_healthy)
else:
response = client.models.generate_content(model="gemini-1.5-pro", contents=prompt)
instructions = response.text if response.text else "No response from Gemini AI."
return instructions