data: code polish
This commit is contained in:
parent
3b499ac7e4
commit
fddf060d92
|
|
@ -24,7 +24,7 @@ abstract class AppDatabase : RoomDatabase() {
|
|||
AppDatabase::class.java,
|
||||
"llama_app_database"
|
||||
)
|
||||
.fallbackToDestructiveMigration()
|
||||
.fallbackToDestructiveMigration(false)
|
||||
.build()
|
||||
INSTANCE = instance
|
||||
instance
|
||||
|
|
|
|||
|
|
@ -36,20 +36,16 @@ sealed class SystemPrompt {
|
|||
override val timestamp: Long = System.currentTimeMillis()
|
||||
) : SystemPrompt() {
|
||||
override val title: String
|
||||
get() = if (timestamp != null) {
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault())
|
||||
dateFormat.format(Date(timestamp))
|
||||
} else {
|
||||
"Custom Prompt"
|
||||
}
|
||||
get() = dataFormat.format(Date(timestamp))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val dataFormat by lazy { SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()) }
|
||||
|
||||
/**
|
||||
* Creates a list of sample presets.
|
||||
*/
|
||||
fun getStaffPickedPrompts(): List<SystemPrompt> {
|
||||
return listOf(
|
||||
val STUB_PRESETS = listOf(
|
||||
Preset(
|
||||
id = "assistant",
|
||||
name = "Helpful Assistant",
|
||||
|
|
@ -72,24 +68,4 @@ sealed class SystemPrompt {
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a placeholder list of recent prompts.
|
||||
* In a real implementation, this would be loaded from the database.
|
||||
*/
|
||||
fun getRecentPrompts(): List<SystemPrompt> {
|
||||
return listOf(
|
||||
Custom(
|
||||
id = "custom-1",
|
||||
content = "You are a technical documentation specialist. When responding, focus on clarity, precision, and structure. Use appropriate technical terminology based on the context, but avoid jargon when simpler terms would suffice. Include examples where helpful, and organize information in a logical manner.",
|
||||
timestamp = System.currentTimeMillis() - 3600000 // 1 hour ago
|
||||
),
|
||||
Custom(
|
||||
id = "custom-2",
|
||||
content = "You are a science educator with expertise in explaining complex concepts in accessible ways. Provide accurate, informative responses that help users understand scientific topics. Use analogies, examples, and clear explanations to make difficult concepts understandable. Cite established scientific consensus and explain levels of certainty when appropriate.",
|
||||
timestamp = System.currentTimeMillis() - 86400000 // 1 day ago
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,12 @@ class SystemPromptRepository(context: Context) {
|
|||
|
||||
private val systemPromptDao = AppDatabase.getDatabase(context).systemPromptDao()
|
||||
|
||||
// Maximum number of recent prompts to keep
|
||||
private val MAX_RECENT_PROMPTS = 10
|
||||
|
||||
/**
|
||||
* Get all preset prompts.
|
||||
*/
|
||||
fun getPresetPrompts(): Flow<List<SystemPrompt>> {
|
||||
// For now, we'll just return the static list since we don't store presets in the database
|
||||
return kotlinx.coroutines.flow.flowOf(SystemPrompt.getStaffPickedPrompts())
|
||||
return kotlinx.coroutines.flow.flowOf(SystemPrompt.STUB_PRESETS)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,4 +102,9 @@ class SystemPromptRepository(context: Context) {
|
|||
suspend fun deleteAllPrompts() {
|
||||
systemPromptDao.deleteAllPrompts()
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Maximum number of recent prompts to keep
|
||||
private const val MAX_RECENT_PROMPTS = 10
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue