diff --git a/app/src/main/kotlin/com/google/ai/sample/GenerativeAiViewModelFactory.kt b/app/src/main/kotlin/com/google/ai/sample/GenerativeAiViewModelFactory.kt index 3801cc6..106cafa 100644 --- a/app/src/main/kotlin/com/google/ai/sample/GenerativeAiViewModelFactory.kt +++ b/app/src/main/kotlin/com/google/ai/sample/GenerativeAiViewModelFactory.kt @@ -35,6 +35,7 @@ enum class ModelOption( val additionalDownloadUrls: List = emptyList(), val requiresVisionBackend: Boolean = false ) { + PUTER_GPT_5_4_NANO("GPT-5.4 Nano (Puter)", "openai/gpt-5.4-nano", ApiProvider.PUTER, supportsScreenshot = true), PUTER_GLM5("GLM-5V Turbo (Puter)", "openrouter:z-ai/glm-5v-turbo", ApiProvider.PUTER, supportsScreenshot = true), MISTRAL_LARGE_3("Mistral Large 3", "mistral-large-latest", ApiProvider.MISTRAL), MISTRAL_MEDIUM_3_1("Mistral Medium 3.1", "mistral-medium-latest", ApiProvider.MISTRAL), diff --git a/app/src/main/kotlin/com/google/ai/sample/MenuScreen.kt b/app/src/main/kotlin/com/google/ai/sample/MenuScreen.kt index 8abd5fb..f189279 100644 --- a/app/src/main/kotlin/com/google/ai/sample/MenuScreen.kt +++ b/app/src/main/kotlin/com/google/ai/sample/MenuScreen.kt @@ -215,10 +215,14 @@ fun MenuScreen( } val normalModels = allModels.filter { it != ModelOption.MISTRAL_MEDIUM_3_1 && + it != ModelOption.PUTER_GPT_5_4_NANO && it.apiProvider != ApiProvider.VERCEL && !STRIKETHROUGH_MODELS.contains(it) } - val orderedModels = listOf(ModelOption.MISTRAL_MEDIUM_3_1) + + val orderedModels = listOf( + ModelOption.PUTER_GPT_5_4_NANO, + ModelOption.MISTRAL_MEDIUM_3_1 + ) + normalModels + vercelModels + STRIKETHROUGH_MODELS @@ -288,7 +292,7 @@ fun MenuScreen( ModelOption.GPT_OSS_120B -> "This is a pure text model\nCerebras sometimes discontinues free access in the Free Tier, displaying an \"Error 404: gpt-oss-120b does not exist or you do not have access to it\" message, or changes the rate limits." ModelOption.MISTRAL_LARGE_3 -> "Mistral AI rejects requests containing non-black images with a 429 Error: Rate limit exceeded response" ModelOption.GEMINI_3_FLASH -> "Google often rejects requests to this model with a 503 Model is exhausted error" - ModelOption.PUTER_GLM5 -> "This model is expensive and uses up the free quota quickly. Consider GPT 5.4 nano" + ModelOption.PUTER_GLM5 -> "This model is expensive and uses up the free quota quickly. Consider GPT-5.4 Nano." ModelOption.GPT_5_1_CODEX_MAX, ModelOption.GPT_5_1_CODEX_MINI, ModelOption.GPT_5_NANO -> "Vercel requires a credit card" diff --git a/app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt b/app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt index b22e1ae..27c35aa 100644 --- a/app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt +++ b/app/src/main/kotlin/com/google/ai/sample/feature/multimodal/PhotoReasoningViewModel.kt @@ -1191,7 +1191,8 @@ class PhotoReasoningViewModel( } // CerebrasRequest braucht stream-Feld — inline als JSON-String um Datenklasse nicht zu ändern - val streamingBody = """{"model":"$modelName","messages":${Json.encodeToString(apiMessages)},"max_completion_tokens":1024,"temperature":0.2,"top_p":1.0,"stream":true}""" + val selectedModelName = com.google.ai.sample.GenerativeAiViewModelFactory.getCurrentModel().modelName + val streamingBody = """{"model":"$selectedModelName","messages":${Json.encodeToString(apiMessages)},"max_completion_tokens":1024,"temperature":0.2,"top_p":1.0,"stream":true}""" val mediaType = "application/json".toMediaType() val client = OkHttpClient() @@ -1859,7 +1860,7 @@ class PhotoReasoningViewModel( context = context, inputContentJson = inputContentJson, chatHistoryJson = chatHistoryJson, - modelName = generativeModel.modelName, + modelName = currentModel.modelName, apiKey = apiKey, apiProvider = currentModel.apiProvider, tempFilePaths = tempFilePaths @@ -2168,30 +2169,10 @@ class PhotoReasoningViewModel( private fun createGenericScreenshotPrompt(): String { val latestTask = latestUserTaskInput.trim() if (latestTask.isNotBlank()) { + latestUserTaskInput = "" return latestTask } - val lastUserMessage = _chatState.getAllMessages() - .asReversed() - .firstOrNull { it.participant == PhotoParticipant.USER && it.text.isNotBlank() } - ?.text - ?.trim() - - if (!lastUserMessage.isNullOrBlank()) { - val screenInfoMarker = "\n\nScreen elements:\n" - return lastUserMessage.substringBefore(screenInfoMarker).trim() - } - - val persistedInput = _userInput.value.trim() - if (persistedInput.isNotBlank()) { - return persistedInput - } - - val lastKnownInput = currentUserInput.trim() - if (lastKnownInput.isNotBlank()) { - return lastKnownInput - } - return "" } diff --git a/build.gradle.kts b/build.gradle.kts index d134f4e..7aad0c2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,19 +1,3 @@ -/* - * Copyright 2023 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - buildscript { dependencies { }