From 3370bd409cb08b7184b2ade43c4c43fa83585def Mon Sep 17 00:00:00 2001 From: Han Yin Date: Sun, 6 Jul 2025 18:01:31 -0700 Subject: [PATCH] remote: add HuggingFaceModelDetails data class --- .../data/remote/HuggingFaceApiService.kt | 2 +- .../data/remote/HuggingFaceModelDetails.kt | 59 +++++++++++++++++++ .../remote/HuggingFaceRemoteDataSource.kt | 2 +- .../llama/data/repository/ModelRepository.kt | 3 +- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceModelDetails.kt diff --git a/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceApiService.kt b/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceApiService.kt index fff89fee44..2508971fce 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceApiService.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceApiService.kt @@ -18,7 +18,7 @@ interface HuggingFaceApiService { ): List @GET("api/models/{modelId}") - suspend fun getModelDetails(@Path("modelId") modelId: String): HuggingFaceModel + suspend fun getModelDetails(@Path("modelId") modelId: String): HuggingFaceModelDetails @GET("{modelId}/resolve/main/{filePath}") @Streaming diff --git a/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceModelDetails.kt b/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceModelDetails.kt new file mode 100644 index 0000000000..d43052388b --- /dev/null +++ b/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceModelDetails.kt @@ -0,0 +1,59 @@ +package com.example.llama.data.remote + +import java.util.Date + +data class HuggingFaceModelDetails( + val _id: String, + val id: String, + val modelId: String, + + val author: String, + val createdAt: Date?, + val lastModified: Date?, + + val library_name: String?, + val pipeline_tag: String?, + val tags: List?, + + val private: Boolean?, + val disabled: Boolean?, + val gated: Boolean?, + + val likes: Int?, + val trendingScore: Int?, // TODO-han.yin: ?? + val downloads: Int?, + + val usedStorage: Long?, + val sha: String?, + + val cardData: CardData?, + val siblings: List?, + val widgetData: List?, + + val gguf: Gguf?, +) { + data class Sibling( + val rfilename: String, + ) + + data class Gguf( + val total: Long?, + val architecture: String?, + val context_length: Int?, + val chat_template: String?, + val bos_token: String?, + val eos_token: String?, + ) + + data class CardData( + val base_model: String?, + val language: List?, + val license: String?, + val pipeline_tag: String?, + val tags: List?, + ) + + data class WidgetData( + val text: String + ) +} diff --git a/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceRemoteDataSource.kt b/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceRemoteDataSource.kt index 8ecfb70dab..f459929ab0 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceRemoteDataSource.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/data/remote/HuggingFaceRemoteDataSource.kt @@ -16,7 +16,7 @@ interface HuggingFaceRemoteDataSource { limit: Int? = 20 ): List - suspend fun getModelDetails(modelId: String): HuggingFaceModel + suspend fun getModelDetails(modelId: String): HuggingFaceModelDetails suspend fun downloadModelFile(modelId: String, filePath: String, outputFile: File): Result } diff --git a/examples/llama.android/app/src/main/java/com/example/llama/data/repository/ModelRepository.kt b/examples/llama.android/app/src/main/java/com/example/llama/data/repository/ModelRepository.kt index f205eb8240..64ec4d6d06 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/data/repository/ModelRepository.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/data/repository/ModelRepository.kt @@ -10,6 +10,7 @@ import com.example.llama.data.local.entity.ModelEntity import com.example.llama.data.model.GgufMetadata import com.example.llama.data.model.ModelInfo import com.example.llama.data.remote.HuggingFaceModel +import com.example.llama.data.remote.HuggingFaceModelDetails import com.example.llama.data.remote.HuggingFaceRemoteDataSource import com.example.llama.data.repository.ModelRepository.ImportProgressTracker import com.example.llama.monitoring.StorageMetrics @@ -89,7 +90,7 @@ interface ModelRepository { /** * Obtain the model details from HuggingFace */ - suspend fun getHuggingFaceModelDetails(modelId: String): HuggingFaceModel + suspend fun getHuggingFaceModelDetails(modelId: String): HuggingFaceModelDetails /** * Download and import a HuggingFace model