You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If Gov API fails or is empty, use AI to fetch realistic market rates
150
+
try {
151
+
val prompt ="""
152
+
You are a real-time agriculture data provider. The user wants current market rates for $commodity in $state, India.
153
+
The government API is down. Generate 3 realistic current Mandi (market) records for this crop in this state.
154
+
Respond strictly with a JSON array of objects with keys: "state", "district", "market", "commodity", "variety", "minPrice", "maxPrice", "modalPrice" (all prices as numbers), "arrivalDate" (DD/MM/YYYY).
155
+
Do not include markdown, just the JSON array.
156
+
""".trimIndent()
157
+
158
+
val aiResponse =GeminiVisionService.chatQuery(prompt)
159
+
if (aiResponse.isSuccess) {
160
+
val jsonStr = aiResponse.getOrNull() ?:""
161
+
val cleanJson = jsonStr.replace("```json", "").replace("```", "").trim()
0 commit comments