Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlinx.coroutines.withContext
import retrofit2.Retrofit
import java.io.IOException
import java.util.concurrent.atomic.AtomicBoolean
import com.example.aisecretary.utils.Logger

class LlamaClient(private val retrofit: Retrofit) {

Expand Down Expand Up @@ -47,6 +48,7 @@ class LlamaClient(private val retrofit: Retrofit) {
}

// Prepare the full prompt with memory and conversation history
Logger.d("LlamaClient", "LLM", "Sending message to LLM: $message")
val fullSystemPrompt = buildEnhancedSystemPrompt(
systemPrompt,
context?.memoryFacts,
Expand All @@ -72,6 +74,7 @@ class LlamaClient(private val retrofit: Retrofit) {

val ollamaResponse = response.body()
if (ollamaResponse != null) {
Logger.i("LlamaClient", "LLM", "LLM response received: ${ollamaResponse.response}")
return@withContext Result.success(ollamaResponse.response)
} else {
// Record error time
Expand Down Expand Up @@ -109,9 +112,11 @@ class LlamaClient(private val retrofit: Retrofit) {
Result.success(Unit)
} else {
Result.failure(IOException("Failed to unload model: ${response.code()} ${response.message()}"))
Logger.e("LlamaClient", "LLM", "Failed to unload model: ${response.code()} ${response.message()}")
}
} catch (e: Exception) {
return@withContext Result.failure(e)
Logger.e("LlamaClient", "LLM", "Exception while unloading model: ${e.message}")
}
}

Expand Down Expand Up @@ -237,4 +242,4 @@ class LlamaClient(private val retrofit: Retrofit) {
"""

}
}
}