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 {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
alias(libs.plugins.kotlin.android)
|
alias(libs.plugins.kotlin.android)
|
||||||
@ -5,20 +8,29 @@ plugins {
|
|||||||
alias(libs.plugins.google.services)
|
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 {
|
android {
|
||||||
namespace = "com.example.ppb_kelompok2"
|
namespace = "com.example.ppb_kelompok2"
|
||||||
compileSdk {
|
compileSdk = 35
|
||||||
version = release(36)
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.example.ppb_kelompok2"
|
applicationId = "com.example.ppb_kelompok2"
|
||||||
minSdk = 25
|
minSdk = 25
|
||||||
targetSdk = 36
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0"
|
versionName = "1.0"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
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 {
|
buildTypes {
|
||||||
@ -39,6 +51,7 @@ android {
|
|||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
|
buildConfig = true // Ensure this is enabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +73,8 @@ dependencies {
|
|||||||
implementation(libs.retrofit)
|
implementation(libs.retrofit)
|
||||||
implementation(libs.retrofit.gson)
|
implementation(libs.retrofit.gson)
|
||||||
implementation(libs.okhttp.logging)
|
implementation(libs.okhttp.logging)
|
||||||
|
implementation(libs.coil.compose)
|
||||||
|
|
||||||
testImplementation(libs.junit)
|
testImplementation(libs.junit)
|
||||||
androidTestImplementation(libs.androidx.junit)
|
androidTestImplementation(libs.androidx.junit)
|
||||||
androidTestImplementation(libs.androidx.espresso.core)
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.example.ppb_kelompok2
|
package com.example.ppb_kelompok2
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
@ -16,7 +18,7 @@ data class EmotionScore(
|
|||||||
val score: Float
|
val score: Float
|
||||||
)
|
)
|
||||||
|
|
||||||
// --- 2. Zero-Shot Classification Models w ---
|
// --- 2. Zero-Shot Classification Models ---
|
||||||
data class ZeroShotRequest(
|
data class ZeroShotRequest(
|
||||||
val inputs: String,
|
val inputs: String,
|
||||||
val parameters: ZeroShotParameters
|
val parameters: ZeroShotParameters
|
||||||
@ -52,13 +54,24 @@ interface HuggingFaceApiService {
|
|||||||
): ZeroShotResponse
|
): ZeroShotResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 4. Singleton Instance ---
|
// --- 4. Singleton Instance (with Logging) ---
|
||||||
object RetrofitClient {
|
object RetrofitClient {
|
||||||
private const val BASE_URL = "https://api-inference.huggingface.co/"
|
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 {
|
val apiService: HuggingFaceApiService by lazy {
|
||||||
Retrofit.Builder()
|
Retrofit.Builder()
|
||||||
.baseUrl(BASE_URL)
|
.baseUrl(BASE_URL)
|
||||||
|
.client(httpClient) // Menggunakan client custom yang sudah ada logger-nya
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
.create(HuggingFaceApiService::class.java)
|
.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"
|
playServicesAuth = "20.7.0"
|
||||||
retrofit = "2.9.0"
|
retrofit = "2.9.0"
|
||||||
okhttp = "4.12.0"
|
okhttp = "4.12.0"
|
||||||
|
coil = "2.5.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
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 = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
|
||||||
retrofit-gson = { group = "com.squareup.retrofit2", name = "converter-gson", 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" }
|
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]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user