diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/AppDatabase.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/AppDatabase.kt index 5eb4b4aa99..4a75781b09 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/AppDatabase.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/AppDatabase.kt @@ -4,6 +4,10 @@ import android.content.Context import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase +import com.example.llama.revamp.data.local.dao.ModelDao +import com.example.llama.revamp.data.local.dao.SystemPromptDao +import com.example.llama.revamp.data.local.entity.ModelEntity +import com.example.llama.revamp.data.local.entity.SystemPromptEntity import javax.inject.Singleton /** diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/converter/GgufMetadataConverters.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/converter/GgufMetadataConverters.kt new file mode 100644 index 0000000000..96fab5fc63 --- /dev/null +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/converter/GgufMetadataConverters.kt @@ -0,0 +1,17 @@ +package com.example.llama.revamp.data.local.converter + +import androidx.room.TypeConverter +import com.example.llama.revamp.util.GgufMetadata +import kotlinx.serialization.json.Json + +class GgufMetadataConverters { + private val json = Json { encodeDefaults = false; ignoreUnknownKeys = true } + + @TypeConverter + fun toJson(value: GgufMetadata?): String? = + value?.let { json.encodeToString(GgufMetadata.serializer(), it) } + + @TypeConverter + fun fromJson(value: String?): GgufMetadata? = + value?.let { json.decodeFromString(GgufMetadata.serializer(), it) } +} diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/ModelDao.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/dao/ModelDao.kt similarity index 89% rename from examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/ModelDao.kt rename to examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/dao/ModelDao.kt index 510a4312cc..f1abcb96ff 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/ModelDao.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/dao/ModelDao.kt @@ -1,10 +1,11 @@ -package com.example.llama.revamp.data.local +package com.example.llama.revamp.data.local.dao import androidx.room.Dao import androidx.room.Delete import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query +import com.example.llama.revamp.data.local.entity.ModelEntity import kotlinx.coroutines.flow.Flow @Dao diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/SystemPromptDao.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/dao/SystemPromptDao.kt similarity index 92% rename from examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/SystemPromptDao.kt rename to examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/dao/SystemPromptDao.kt index 786583f4ed..1de732e1e0 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/SystemPromptDao.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/dao/SystemPromptDao.kt @@ -1,10 +1,11 @@ -package com.example.llama.revamp.data.local +package com.example.llama.revamp.data.local.dao import androidx.room.Dao import androidx.room.Delete import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query +import com.example.llama.revamp.data.local.entity.SystemPromptEntity import kotlinx.coroutines.flow.Flow /** diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/ModelEntity.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/entity/ModelEntity.kt similarity index 84% rename from examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/ModelEntity.kt rename to examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/entity/ModelEntity.kt index 60e6a60105..ada6926a4f 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/ModelEntity.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/entity/ModelEntity.kt @@ -1,11 +1,11 @@ -package com.example.llama.revamp.data.local +package com.example.llama.revamp.data.local.entity import androidx.room.Entity import androidx.room.PrimaryKey import androidx.room.TypeConverters +import com.example.llama.revamp.data.local.converter.GgufMetadataConverters import com.example.llama.revamp.data.model.ModelInfo import com.example.llama.revamp.util.GgufMetadata -import com.example.llama.revamp.util.GgufMetadataConverters @Entity(tableName = "models") diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/SystemPromptEntity.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/entity/SystemPromptEntity.kt similarity index 97% rename from examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/SystemPromptEntity.kt rename to examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/entity/SystemPromptEntity.kt index 2ad77818d7..6e5897d0aa 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/SystemPromptEntity.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/local/entity/SystemPromptEntity.kt @@ -1,4 +1,4 @@ -package com.example.llama.revamp.data.local +package com.example.llama.revamp.data.local.entity import androidx.room.Entity import androidx.room.PrimaryKey diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/ModelRepository.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/ModelRepository.kt index 1a96f77920..2fd2ee74ee 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/ModelRepository.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/ModelRepository.kt @@ -4,8 +4,8 @@ import android.content.Context import android.net.Uri import android.os.StatFs import android.util.Log -import com.example.llama.revamp.data.local.ModelDao -import com.example.llama.revamp.data.local.ModelEntity +import com.example.llama.revamp.data.local.dao.ModelDao +import com.example.llama.revamp.data.local.entity.ModelEntity import com.example.llama.revamp.data.model.ModelInfo import com.example.llama.revamp.data.repository.ModelRepository.ImportProgressTracker import com.example.llama.revamp.util.GgufMetadataReader diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/SystemPromptRepository.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/SystemPromptRepository.kt index edc79d74e0..ef32801dea 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/SystemPromptRepository.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/data/repository/SystemPromptRepository.kt @@ -1,7 +1,7 @@ package com.example.llama.revamp.data.repository -import com.example.llama.revamp.data.local.SystemPromptDao -import com.example.llama.revamp.data.local.SystemPromptEntity +import com.example.llama.revamp.data.local.dao.SystemPromptDao +import com.example.llama.revamp.data.local.entity.SystemPromptEntity import com.example.llama.revamp.data.model.SystemPrompt import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first diff --git a/examples/llama.android/app/src/main/java/com/example/llama/revamp/util/GgufMetadata.kt b/examples/llama.android/app/src/main/java/com/example/llama/revamp/util/GgufMetadata.kt index 4172b6aebc..6a95d0502c 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/revamp/util/GgufMetadata.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/revamp/util/GgufMetadata.kt @@ -1,8 +1,6 @@ package com.example.llama.revamp.util -import androidx.room.TypeConverter import kotlinx.serialization.Serializable -import kotlinx.serialization.json.Json import java.io.IOException @@ -189,18 +187,6 @@ data class GgufMetadata( ) } -class GgufMetadataConverters { - private val json = Json { encodeDefaults = false; ignoreUnknownKeys = true } - - @TypeConverter - fun toJson(value: GgufMetadata?): String? = - value?.let { json.encodeToString(GgufMetadata.serializer(), it) } - - @TypeConverter - fun fromJson(value: String?): GgufMetadata? = - value?.let { json.decodeFromString(GgufMetadata.serializer(), it) } -} - /** * Numerical codes used by `general.file_type` (see llama.cpp repo's `constants.py`). * The `label` matches what llama‑cli prints.