Skip to content

Commit

Permalink
Push works
Browse files Browse the repository at this point in the history
  • Loading branch information
cheroliv committed Sep 25, 2024
1 parent 72d3e9e commit ebb2f03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
24 changes: 13 additions & 11 deletions buildSrc/src/main/kotlin/school/ai/AssistantManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ import dev.langchain4j.model.output.Response
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.suspendCancellableCoroutine
import org.gradle.api.Project
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
import java.time.Duration
import java.time.Duration.ofSeconds
import java.util.*
import kotlin.coroutines.resume
import org.slf4j.LoggerFactory


@Suppress("MemberVisibilityCanBePrivate")
object AssistantManager {

val logger = LoggerFactory.getLogger(AssistantPlugin::class.java)
val logger: Logger = LoggerFactory.getLogger(AssistantPlugin::class.java)

@JvmStatic
val Project.localModels
Expand Down Expand Up @@ -59,20 +61,20 @@ object AssistantManager {

fun Project.createOllamaChatModel(model: String = "smollm:135m"): OllamaChatModel =
OllamaChatModel.builder().apply {
baseUrl(project.findProperty("ollama.baseUrl") as? String ?: "http://localhost:11434")
modelName(project.findProperty("ollama.modelName") as? String ?: model)
temperature(project.findProperty("ollama.temperature") as? Double ?: 0.8)
timeout(Duration.ofSeconds(project.findProperty("ollama.timeout") as? Long ?: 6_000))
baseUrl(findProperty("ollama.baseUrl") as? String ?: "http://localhost:11434")
modelName(findProperty("ollama.modelName") as? String ?: model)
temperature(findProperty("ollama.temperature") as? Double ?: 0.8)
timeout(ofSeconds(findProperty("ollama.timeout") as? Long ?: 6_000))
logRequests(true)
logResponses(true)
}.build()

fun Project.createOllamaStreamingChatModel(model: String = "smollm:135m"): OllamaStreamingChatModel =
OllamaStreamingChatModel.builder().apply {
baseUrl(project.findProperty("ollama.baseUrl") as? String ?: "http://localhost:11434")
modelName(project.findProperty("ollama.modelName") as? String ?: model)
temperature(project.findProperty("ollama.temperature") as? Double ?: 0.8)
timeout(Duration.ofSeconds(project.findProperty("ollama.timeout") as? Long ?: 6_000))
baseUrl(findProperty("ollama.baseUrl") as? String ?: "http://localhost:11434")
modelName(findProperty("ollama.modelName") as? String ?: model)
temperature(findProperty("ollama.temperature") as? Double ?: 0.8)
timeout(ofSeconds(findProperty("ollama.timeout") as? Long ?: 6_000))
logRequests(true)
logResponses(true)
}.build()
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/school/ai/AssistantPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class AssistantPlugin : Plugin<Project> {
}
}


// Generic function for chat model tasks
fun createChatTask(taskName: String, model: String) {
task(taskName) {
Expand Down

0 comments on commit ebb2f03

Please sign in to comment.