Skip to content

Commit a197083

Browse files
committed
Fix vision models to official Groq Llama vision, enforce JSON without raw thinking text, set instant market default load
1 parent 64f3e86 commit a197083

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

app/src/main/java/com/example/GeminiVisionService.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ object GeminiVisionService {
3636
"llama-3.1-8b-instant"
3737
)
3838

39-
private val VISION_MODELS = listOf("qwen/qwen3.6-27b")
39+
private val VISION_MODELS = listOf(
40+
"llama-3.2-11b-vision-preview",
41+
"llama-3.2-90b-vision-preview"
42+
)
4043

4144
private fun parseText(body: String): String {
4245
if (body.isBlank()) return "API Error: Empty response from Groq server"
@@ -62,7 +65,7 @@ object GeminiVisionService {
6265
val langName = LanguageManager.getLanguageName(lang)
6366
val translationInstruction = if (lang != "en") " YOU MUST RESPOND ENTIRELY AND STRICTLY IN THE $langName LANGUAGE. However, if a JSON format is requested, keep the JSON structure and keys strictly in English, and only translate the values." else ""
6467

65-
val finalPrompt = prompt + translationInstruction + "\nCRITICAL: Answer extremely concisely, maximum 1 sentence per field."
68+
val finalPrompt = prompt + translationInstruction + "\nCRITICAL: Respond ONLY with a single raw JSON object. DO NOT include any reasoning, chain of thought, intro text, or markdown code blocks."
6669
val escapedPrompt = finalPrompt.replace("\\", "\\\\").replace("\"", "\\\"", false).replace("\n", "\\n", false)
6770

6871
for (model in VISION_MODELS) {
@@ -71,6 +74,7 @@ object GeminiVisionService {
7174
val body = """
7275
{
7376
"model": "$model",
77+
"response_format": {"type": "json_object"},
7478
"messages": [
7579
{
7680
"role": "user",

app/src/main/java/com/example/MarketScreen.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ fun MarketScreen(modifier: Modifier = Modifier) {
3131
val context = LocalContext.current
3232
val lang = LanguageManager.currentLanguage.collectAsState().value
3333

34-
var query by remember { mutableStateOf("") }
35-
var activeSearchQuery by remember { mutableStateOf("") }
36-
var userState by remember { mutableStateOf("") }
37-
var activeSearchState by remember { mutableStateOf("") }
34+
var query by remember { mutableStateOf("Wheat") }
35+
var activeSearchQuery by remember { mutableStateOf("Wheat") }
36+
var userState by remember { mutableStateOf("Maharashtra") }
37+
var activeSearchState by remember { mutableStateOf("Maharashtra") }
3838
var userMandi by remember { mutableStateOf("") }
3939

4040
var detectingLoc by remember { mutableStateOf(false) }
@@ -49,20 +49,22 @@ fun MarketScreen(modifier: Modifier = Modifier) {
4949
val loc = LocationHelper.getCurrentLocationStateAndMandi(context)
5050
if (loc != null) {
5151
userState = loc.first
52+
activeSearchState = loc.first
5253
userMandi = loc.second
5354
}
5455
detectingLoc = false
5556
}
5657
}
5758
}
5859

59-
// Auto-detect location if available but don't force a search until user hits Search
60+
// Auto-detect location if available and set activeSearchState
6061
LaunchedEffect(Unit) {
6162
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
6263
val loc = LocationHelper.getCurrentLocationStateAndMandi(context)
6364
if (loc != null) {
64-
if (userState.isEmpty()) userState = loc.first
65-
if (userMandi.isEmpty()) userMandi = loc.second
65+
userState = loc.first
66+
activeSearchState = loc.first
67+
userMandi = loc.second
6668
}
6769
}
6870
}

web/public/NuKropAI_v1.0.apk

182 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)