data: define data models for LLM and system prompts

This commit is contained in:
Han Yin 2025-04-11 14:35:52 -07:00
parent 697d778db7
commit 3787fbddb0
2 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,77 @@
package com.example.llama.revamp.data.model
/**
* Data class containing information about an LLM model.
*/
data class ModelInfo(
val id: String,
val name: String,
val path: String,
val sizeInBytes: Long,
val parameters: String,
val quantization: String,
val type: String,
val contextLength: Int,
val lastUsed: Long? = null
) {
val formattedSize: String
get() {
return when {
sizeInBytes >= 1_000_000_000 -> {
val sizeInGb = sizeInBytes / 1_000_000_000.0
String.format("%.2f GB", sizeInGb)
}
sizeInBytes >= 1_000_000 -> {
val sizeInMb = sizeInBytes / 1_000_000.0
String.format("%.2f MB", sizeInMb)
}
else -> {
val sizeInKb = sizeInBytes / 1_000.0
String.format("%.2f KB", sizeInKb)
}
}
}
companion object {
/**
* Creates a list of sample models for development and testing.
*/
fun getSampleModels(): List<ModelInfo> {
return listOf(
ModelInfo(
id = "mistral-7b",
name = "Mistral 7B",
path = "/storage/models/mistral-7b-q4_0.gguf",
sizeInBytes = 4_000_000_000,
parameters = "7B",
quantization = "Q4_K_M",
type = "Mistral",
contextLength = 8192,
lastUsed = System.currentTimeMillis() - 86400000 // 1 day ago
),
ModelInfo(
id = "llama2-13b",
name = "Llama 2 13B",
path = "/storage/models/llama2-13b-q5_k_m.gguf",
sizeInBytes = 8_500_000_000,
parameters = "13B",
quantization = "Q5_K_M",
type = "Llama",
contextLength = 4096,
lastUsed = System.currentTimeMillis() - 259200000 // 3 days ago
),
ModelInfo(
id = "phi-2",
name = "Phi-2",
path = "/storage/models/phi-2.gguf",
sizeInBytes = 2_800_000_000,
parameters = "2.7B",
quantization = "Q4_0",
type = "Phi",
contextLength = 2048,
lastUsed = null
)
)
}
}
}

View File

@ -0,0 +1,74 @@
package com.example.llama.revamp.data.model
/**
* Data class representing a system prompt for LLM.
*/
data class SystemPrompt(
val id: String,
val name: String,
val content: String,
val category: Category,
val lastUsed: Long? = null
) {
enum class Category {
STAFF_PICK,
USER_CREATED,
RECENT
}
companion object {
/**
* Creates a list of sample system prompts for development and testing.
*/
fun getStaffPickedPrompts(): List<SystemPrompt> {
return listOf(
SystemPrompt(
id = "assistant",
name = "Helpful Assistant",
content = "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should be informative and engaging. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.",
category = Category.STAFF_PICK
),
SystemPrompt(
id = "coder",
name = "Coding Assistant",
content = "You are a helpful programming assistant. When asked coding questions, provide clear and functional code examples when applicable. If a question is ambiguous, ask for clarification. Focus on providing accurate solutions with good coding practices and explain your solutions.",
category = Category.STAFF_PICK
),
SystemPrompt(
id = "summarizer",
name = "Text Summarizer",
content = "You are a helpful assistant that specializes in summarizing text. When provided with a text, create a concise summary that captures the main points, key details, and overall message. Adjust summary length based on original content length. Maintain factual accuracy and avoid adding information not present in the original text.",
category = Category.STAFF_PICK
),
SystemPrompt(
id = "creative",
name = "Creative Writer",
content = "You are a creative writing assistant with a vivid imagination. Help users draft stories, poems, scripts, and other creative content. Provide imaginative ideas while following the user's specifications. When responding, focus on being original, engaging, and matching the requested tone and style.",
category = Category.STAFF_PICK
)
)
}
/**
* Get recent system prompts (would normally be from storage)
*/
fun getRecentPrompts(): List<SystemPrompt> {
return listOf(
SystemPrompt(
id = "custom-1",
name = "Technical Writer",
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.",
category = Category.USER_CREATED,
lastUsed = System.currentTimeMillis() - 3600000 // 1 hour ago
),
SystemPrompt(
id = "custom-2",
name = "Science Educator",
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.",
category = Category.USER_CREATED,
lastUsed = System.currentTimeMillis() - 86400000 // 1 day ago
)
)
}
}
}