Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum class ModelOption(
val additionalDownloadUrls: List<String> = 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),
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/kotlin/com/google/ai/sample/MenuScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ""
}

Expand Down
16 changes: 0 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
}
Expand Down
Loading