Compare commits
8 Commits
7fe8f9a0df
...
2365e0b907
| Author | SHA1 | Date | |
|---|---|---|---|
| 2365e0b907 | |||
|
|
6602e0e143 | ||
|
|
5ae0b78497 | ||
|
|
b7315ea5c0 | ||
| 7046948c70 | |||
|
|
d0b773b6ef | ||
|
|
6d21baa3f3 | ||
|
|
a83e671ece |
@ -1,3 +1,6 @@
|
||||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
@ -5,20 +8,29 @@ plugins {
|
||||
alias(libs.plugins.google.services)
|
||||
}
|
||||
|
||||
// Load properties from local.properties file
|
||||
val localProperties = Properties()
|
||||
val localPropertiesFile = rootProject.file("local.properties")
|
||||
if (localPropertiesFile.exists()) {
|
||||
localProperties.load(FileInputStream(localPropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.ppb_kelompok2"
|
||||
compileSdk {
|
||||
version = release(36)
|
||||
}
|
||||
compileSdk = 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.example.ppb_kelompok2"
|
||||
minSdk = 25
|
||||
targetSdk = 36
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
// Expose the API key as a BuildConfig field
|
||||
// This reads the HF_API_KEY from your local.properties file
|
||||
buildConfigField("String", "HF_API_KEY", "\"${localProperties.getProperty("HF_API_KEY") ?: ""}\"")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@ -39,6 +51,7 @@ android {
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true // Ensure this is enabled
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +73,8 @@ dependencies {
|
||||
implementation(libs.retrofit)
|
||||
implementation(libs.retrofit.gson)
|
||||
implementation(libs.okhttp.logging)
|
||||
implementation(libs.coil.compose)
|
||||
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.example.ppb_kelompok2
|
||||
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import retrofit2.http.Body
|
||||
@ -16,7 +18,7 @@ data class EmotionScore(
|
||||
val score: Float
|
||||
)
|
||||
|
||||
// --- 2. Zero-Shot Classification Models w ---
|
||||
// --- 2. Zero-Shot Classification Models ---
|
||||
data class ZeroShotRequest(
|
||||
val inputs: String,
|
||||
val parameters: ZeroShotParameters
|
||||
@ -52,13 +54,24 @@ interface HuggingFaceApiService {
|
||||
): ZeroShotResponse
|
||||
}
|
||||
|
||||
// --- 4. Singleton Instance ---
|
||||
// --- 4. Singleton Instance (with Logging) ---
|
||||
object RetrofitClient {
|
||||
private const val BASE_URL = "https://api-inference.huggingface.co/"
|
||||
|
||||
// Membuat Interceptor untuk logging. Level BODY akan menampilkan semua detail request/response.
|
||||
private val loggingInterceptor = HttpLoggingInterceptor().apply {
|
||||
level = HttpLoggingInterceptor.Level.BODY
|
||||
}
|
||||
|
||||
// Menambahkan interceptor ke OkHttpClient
|
||||
private val httpClient = OkHttpClient.Builder()
|
||||
.addInterceptor(loggingInterceptor)
|
||||
.build()
|
||||
|
||||
val apiService: HuggingFaceApiService by lazy {
|
||||
Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.client(httpClient) // Menggunakan client custom yang sudah ada logger-nya
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build()
|
||||
.create(HuggingFaceApiService::class.java)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ firebaseBom = "33.1.2"
|
||||
playServicesAuth = "20.7.0"
|
||||
retrofit = "2.9.0"
|
||||
okhttp = "4.12.0"
|
||||
coil = "2.5.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
@ -36,6 +37,7 @@ play-services-auth = { group = "com.google.android.gms", name = "play-services-a
|
||||
retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
|
||||
retrofit-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit" }
|
||||
okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" }
|
||||
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user