feat: история общения (SQLite) + Koog LLM-клиент в app-phone
SQLite (голый SQLiteOpenHelper, без ORM — как решили): - sessions (id, title, created_at, updated_at) + messages (role, content, tool_call_id, tool_calls JSON, attachments JSON, created_at) по утверждённой схеме; FK-каскад; CHECK на роли. - ChatDb + ChatDao (createSession/listSessions/rename/touch/delete, addMessage, messagesForSession), доступ через PhoneApp.chatDao. - Unit: ModelsTest (роли, JSON tool_calls/attachments). androidTest: ChatDaoTest — CRUD-круг + каскад — OK (3 tests) на эмуляторе. Koog (JetBrains) — базовый LLM-клиент, без агентного слоя: - ai.koog:prompt-executor-openai-client:1.1.1 + http-client-okhttp - LlmClient: OpenAILLMClient(apiKey, baseUrl=llm.binom.pw) → chat(история) - BuildConfig LLM_API_KEY/LLM_MODEL из local.properties (вне git); llm_debug smoke (--ez llm_debug true) — проверен на эмуляторе: реальный ответ от llm.binom.pw (deepseek-v4-flash). - ЗАГЛУШКА Coroutines_jvmKt: дефект публикации Koog 1.1.1 — utils-android не включает jvm-класс, который зовёт OkHttpKoogHttpClient (без неё NoClassDefFoundError на первом вызове). Сигнатура сверена с utils-jvm. Убрать после фикса JetBrains.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
@@ -5,6 +7,28 @@ plugins {
|
||||
alias(libs.plugins.compose.compiler)
|
||||
}
|
||||
|
||||
// LLM-ключ из local.properties (llm.apiKey) — файл вне git; пустой = ещё не задан.
|
||||
// providers.gradleProperty не читает local.properties, поэтому грузим файл вручную.
|
||||
val llmApiKey: String = run {
|
||||
val props = Properties()
|
||||
val local = rootProject.file("local.properties")
|
||||
if (local.exists()) local.inputStream().use(props::load)
|
||||
props.getProperty("llm.apiKey", "")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\"")
|
||||
}
|
||||
|
||||
// Модель для ассистента — из local.properties (llm.model), вне git.
|
||||
// Дефолт — быстрая дешёвая (пользователь укажет боевую).
|
||||
val llmModel: String = run {
|
||||
val props = Properties()
|
||||
val local = rootProject.file("local.properties")
|
||||
if (local.exists()) local.inputStream().use(props::load)
|
||||
props.getProperty("llm.model", "Routerai/deepseek/deepseek-v4-flash")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\"")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "pw.binom.viewmate.phone"
|
||||
compileSdk = 35
|
||||
@@ -15,6 +39,12 @@ android {
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "0.1.0"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
// LLM-ключ из local.properties (llm.apiKey) — вне git; пустой = ещё не задан
|
||||
buildConfigField("String", "LLM_API_KEY", "\"$llmApiKey\"")
|
||||
// Модель ассистента — из local.properties (llm.model), вне git
|
||||
buildConfigField("String", "LLM_MODEL", "\"$llmModel\"")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -36,6 +66,14 @@ android {
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
packaging {
|
||||
resources {
|
||||
// okhttp-sse 5.x и jspecify оба кладут этот OSGI-manifest
|
||||
excludes += "META-INF/versions/9/OSGI-INF/MANIFEST.MF"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,6 +94,10 @@ dependencies {
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
implementation(project(":lib-core"))
|
||||
|
||||
// Koog (JetBrains) — LLM-клиент (OpenAI-совместимый)
|
||||
implementation(libs.koog.openai.client)
|
||||
implementation(libs.koog.http.client.okhttp)
|
||||
|
||||
// Офлайн-распознавание речи (sherpa-onnx + Whisper), JitPack
|
||||
implementation("com.github.k2-fsa.sherpa-onnx:sherpa-onnx:v1.13.6")
|
||||
|
||||
@@ -71,4 +113,7 @@ dependencies {
|
||||
testImplementation("io.ktor:ktor-client-content-negotiation:3.3.0")
|
||||
testImplementation("io.ktor:ktor-serialization-kotlinx-json:3.3.0")
|
||||
testImplementation(libs.kotlinx.coroutines.test)
|
||||
|
||||
androidTestImplementation("androidx.test.ext:junit:1.2.1")
|
||||
androidTestImplementation("androidx.test:runner:1.6.2")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user