add find_ai_model.md guide and integrate StatusMessageService into TranslationViewModel
This commit is contained in:
87
app/src/main/assets/hints/find_ai_model.md
Normal file
87
app/src/main/assets/hints/find_ai_model.md
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# How to Scan for AI Models
|
||||||
|
# TODO REWRITE
|
||||||
|
|
||||||
|
This guide explains how to use the **Scan** feature to discover and add AI models to your app.
|
||||||
|
|
||||||
|
## How Scanning Works
|
||||||
|
|
||||||
|
The scan feature searches for available AI models on your device or network.
|
||||||
|
|
||||||
|
> **Note:** Results depend on your API key permissions.
|
||||||
|
|
||||||
|
### Key Points
|
||||||
|
|
||||||
|
- Only public models are shown by default
|
||||||
|
- Private models require additional setup
|
||||||
|
- Try again if no models are found
|
||||||
|
|
||||||
|
## Why Some Models Are Missing
|
||||||
|
|
||||||
|
Some models may not appear in the scan results due to:
|
||||||
|
|
||||||
|
| Reason | Description | Icon |
|
||||||
|
|--------|-------------|------|
|
||||||
|
| Restricted access | Model requires special permissions | 🔒 |
|
||||||
|
| Not suitable | Model type not supported | ⚠️ |
|
||||||
|
| Text only | Only text-based models are supported | ✓ |
|
||||||
|
|
||||||
|
### Model Tiers
|
||||||
|
|
||||||
|
We recommend these tiers for optimal performance:
|
||||||
|
|
||||||
|
- **Nano** - Fastest, for simple tasks
|
||||||
|
- **Mini** - Balanced speed and capability
|
||||||
|
- **Small** - Good for most tasks
|
||||||
|
- **Medium** - More capable, slower
|
||||||
|
- **Large** - Most capable, paid only
|
||||||
|
|
||||||
|
## Tips for Success
|
||||||
|
|
||||||
|
1. **Verify your API key** is active and has correct permissions
|
||||||
|
2. **Select the correct organization** from your account
|
||||||
|
3. **Type model names manually** if scanning doesn't find them
|
||||||
|
4. **Prefer instruct or chat models** for text generation
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
// Example: Manual model addition
|
||||||
|
val model = Model(
|
||||||
|
name = "llama3.2",
|
||||||
|
type = ModelType.TEXT,
|
||||||
|
provider = "ollama"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Visual Guide
|
||||||
|
|
||||||
|
### Step 1: Initiate Scan
|
||||||
|
|
||||||
|
Click the scan button to search for available models.
|
||||||
|
|
||||||
|
### Step 2: Select Model Type
|
||||||
|
|
||||||
|
Choose between different model categories:
|
||||||
|
|
||||||
|
- **Text Chat** - For conversational AI
|
||||||
|
- **Instruct** - For direct instructions
|
||||||
|
- **Complete** - For text completion
|
||||||
|
|
||||||
|
### Step 3: Add & Validate
|
||||||
|
|
||||||
|
Add the selected model and validate it works correctly.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Can't Find Your Model?
|
||||||
|
|
||||||
|
If your model doesn't appear in the scan results:
|
||||||
|
|
||||||
|
1. Check if the model is running locally or accessible via API
|
||||||
|
2. Verify network connectivity
|
||||||
|
3. Try adding it manually by entering the model details
|
||||||
|
|
||||||
|
> **Pro Tip:** You can always add models manually by clicking the "+" button in the models screen.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Last updated: 2024-01-15*
|
||||||
|
*For more help, visit our documentation website.*
|
||||||
@@ -117,6 +117,7 @@ class TranslationService(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun translateSentence(sentence: String): Result<TranslationHistoryItem> = withContext(Dispatchers.IO) {
|
suspend fun translateSentence(sentence: String): Result<TranslationHistoryItem> = withContext(Dispatchers.IO) {
|
||||||
|
val statusMessageService = StatusMessageService
|
||||||
val additionalInstructions = settingsRepository.customPromptTranslation.flow.first()
|
val additionalInstructions = settingsRepository.customPromptTranslation.flow.first()
|
||||||
val selectedSource = languageRepository.loadSelectedSourceLanguage().first()
|
val selectedSource = languageRepository.loadSelectedSourceLanguage().first()
|
||||||
val sourceLangName = selectedSource?.englishName ?: "Auto"
|
val sourceLangName = selectedSource?.englishName ?: "Auto"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import eu.gaudian.translator.model.repository.dataStore
|
|||||||
import eu.gaudian.translator.model.repository.loadObjectList
|
import eu.gaudian.translator.model.repository.loadObjectList
|
||||||
import eu.gaudian.translator.model.repository.saveObjectList
|
import eu.gaudian.translator.model.repository.saveObjectList
|
||||||
import eu.gaudian.translator.utils.Log
|
import eu.gaudian.translator.utils.Log
|
||||||
|
import eu.gaudian.translator.utils.StatusMessageService
|
||||||
import eu.gaudian.translator.utils.TextToSpeechHelper
|
import eu.gaudian.translator.utils.TextToSpeechHelper
|
||||||
import eu.gaudian.translator.utils.TranslationService
|
import eu.gaudian.translator.utils.TranslationService
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
@@ -31,6 +32,9 @@ class TranslationViewModel @Inject constructor(
|
|||||||
val languageRepository: LanguageRepository
|
val languageRepository: LanguageRepository
|
||||||
) : AndroidViewModel(application) {
|
) : AndroidViewModel(application) {
|
||||||
|
|
||||||
|
private val statusMessageService = StatusMessageService
|
||||||
|
|
||||||
|
|
||||||
// For back/forward navigation of history in the UI (like editors)
|
// For back/forward navigation of history in the UI (like editors)
|
||||||
private val _historyCursor = MutableStateFlow(-1)
|
private val _historyCursor = MutableStateFlow(-1)
|
||||||
|
|
||||||
@@ -112,11 +116,13 @@ class TranslationViewModel @Inject constructor(
|
|||||||
fun translateSentence(sentence: String) {
|
fun translateSentence(sentence: String) {
|
||||||
val sentenceToTranslate = sentence.ifEmpty { _inputText.value }
|
val sentenceToTranslate = sentence.ifEmpty { _inputText.value }
|
||||||
if (sentenceToTranslate.isBlank()) {
|
if (sentenceToTranslate.isBlank()) {
|
||||||
|
statusMessageService.showSimpleMessage("Please enter a sentence to translate.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedTranslationModel.value == null) {
|
if (selectedTranslationModel.value == null) {
|
||||||
Log.e("TranslationViewModel", "Cannot translate because no model is selected.")
|
Log.e("TranslationViewModel", "Cannot translate because no model is selected.")
|
||||||
|
statusMessageService.showSimpleMessage("Cannot translate because no model is selected.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +157,7 @@ class TranslationViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
.onFailure { exception ->
|
.onFailure { exception ->
|
||||||
Log.e("TranslationViewModel", "Translation failed: ${exception.message}")
|
Log.e("TranslationViewModel", "Translation failed: ${exception.message}")
|
||||||
|
statusMessageService.showErrorMessage("Translation failed: ${exception.message}")
|
||||||
}
|
}
|
||||||
|
|
||||||
_isTranslating.value = false
|
_isTranslating.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user