Skip to content

Commit

Permalink
The code changes suggest updates to user signup and AI translator fun…
Browse files Browse the repository at this point in the history
…ctionality.

For user signup:  The change from returning a UUID to a Long after saving user activation data likely reflects a shift in the underlying database schema or a move to a different ID generation strategy.  Instead of returning the generated UUID of the new record, the code now returns the number of rows updated, which should always be 1 in a successful user activation save operation.  This simplifies the response and potentially improves performance slightly.  It also implies a reliance on auto-generated IDs at the database level.

For the AI translator: Several modifications are apparent.  The list of available AI models has expanded, including new models like GraniteCode, CodeGemma, and YiCoder, with variations in size indicated by labels like "Tiny" and "Small".  The change in how Ollama chat models are built suggests a simplification. The commented-out lines related to setting the base URL, model name, and temperature from environment variables or properties indicate a potential shift to default values or a different configuration mechanism. The naming changes, removing the `dev.langchain4j.model.ollama` prefix, likely reflect changes in dependency management or internal project structure.  Overall, the changes suggest an expansion of model options and a streamlining of the Ollama model initialization.
  • Loading branch information
cheroliv committed Nov 17, 2024
1 parent b4a0eee commit 6e8e41c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ class AiTranslatorController(service: ChatModelService) {
get() = setOf(
"llama3.2:3b" to "LlamaTiny",
"llama3.1:8b" to "LlamaSmall",
"mistral:7b" to "Mistral",
"aya:8b" to "Aya",
"mistral:7b" to "MistralSmall",
"aya:8b" to "AyaSmall",
"phi3.5:3.8b" to "Phi",
"smollm:135m" to "SmollM"
"smollm:135m" to "SmollM",
"granite-code:3b" to "GraniteCodeTiny",
"codegemma:2b" to "CodeGemmaTiny",
"yi-coder:1.5b" to "YiCoderTiny",
"yi-coder:9b" to "YiCoderSmall"
)

// Creating tasks for each model
Expand All @@ -70,7 +74,7 @@ class AiTranslatorController(service: ChatModelService) {
}

fun ApplicationContext.createOllamaChatModel(model: String = "smollm:135m"): OllamaChatModel =
dev.langchain4j.model.ollama.OllamaChatModel.builder().apply {
OllamaChatModel.builder().apply {
baseUrl(environment.getProperty("ollama.baseUrl") as? String ?: "http://localhost:11434")
// modelName(findProperty("ollama.modelName") as? String ?: model)
// temperature(findProperty("ollama.temperature") as? Double ?: 0.8)
Expand All @@ -80,7 +84,7 @@ class AiTranslatorController(service: ChatModelService) {
}.build()

fun ApplicationContext.createOllamaStreamingChatModel(model: String = "smollm:135m"): OllamaStreamingChatModel =
dev.langchain4j.model.ollama.OllamaStreamingChatModel.builder().apply {
OllamaStreamingChatModel.builder().apply {
// baseUrl(findProperty("ollama.baseUrl") as? String ?: "http://localhost:11434")
// modelName(findProperty("ollama.modelName") as? String ?: model)
// temperature(findProperty("ollama.temperature") as? Double ?: 0.8)
Expand Down
7 changes: 3 additions & 4 deletions api/src/main/kotlin/school/users/signup/Signup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.springframework.context.ApplicationContext
import org.springframework.dao.EmptyResultDataAccessException
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate
import org.springframework.r2dbc.core.awaitOne
import org.springframework.r2dbc.core.awaitRowsUpdated
import school.users.User.UserDao
import school.users.User.UserDao.Constraints.LOGIN_REGEX
import school.users.User.UserDao.Constraints.PASSWORD_MAX
Expand Down Expand Up @@ -118,7 +119,7 @@ data class Signup(

object Dao {
@Throws(EmptyResultDataAccessException::class)
suspend fun Pair<UserActivation, ApplicationContext>.save(): Either<Throwable, UUID> = try {
suspend fun Pair<UserActivation, ApplicationContext>.save(): Either<Throwable, Long> = try {
second.getBean<R2dbcEntityTemplate>()
.databaseClient
.sql(INSERT.trimIndent())
Expand All @@ -127,9 +128,7 @@ data class Signup(
.bind(CREATED_DATE_ATTR, first.createdDate)
.bind(ACTIVATION_DATE_ATTR, first.activationDate)
.fetch()
.awaitOne()[ID_ATTR.uppercase()]
.toString()
.run(UUID::fromString)
.awaitRowsUpdated()
.right()
} catch (e: Throwable) {
e.left()
Expand Down

0 comments on commit 6e8e41c

Please sign in to comment.