From ea63b66f0f2699b4f58bfaf1b9a4d0aaa0203a52 Mon Sep 17 00:00:00 2001 From: kpavlov <1517853+kpavlov@users.noreply.github.com> Date: Thu, 1 May 2025 09:57:03 +0300 Subject: [PATCH] Use explicit api Switch to [Explicit API](https://kotlinlang.org/docs/whatsnew14.html#explicit-api-mode-for-library-authors) mode --- langchain4j-kotlin/pom.xml | 5 --- .../langchain4j/kotlin/Configuration.kt | 10 ++--- .../kpavlov/langchain4j/kotlin/TypeAliases.kt | 8 ++-- .../adapters/TokenStreamToReplyFlowAdapter.kt | 12 +++--- .../TokenStreamToStringFlowAdapter.kt | 6 +-- .../model/chat/ChatLanguageModelExtensions.kt | 8 ++-- .../StreamingChatLanguageModelExtensions.kt | 14 +++---- .../chat/request/ChatRequestExtensions.kt | 41 ++++++++++--------- .../kotlin/prompt/PromptTemplate.kt | 4 +- .../kotlin/prompt/PromptTemplateSource.kt | 4 +- .../kotlin/prompt/RenderablePromptTemplate.kt | 4 +- .../kotlin/service/SystemMessageProvider.kt | 7 ++-- .../service/TemplateSystemMessageProvider.kt | 6 +-- .../kpavlov/langchain4j/kotlin/Documents.kt | 2 +- .../langchain4j/kotlin/TestEnvironment.kt | 2 +- .../kotlin/adapters/ServiceWithFlowTest.kt | 2 +- .../data/document/MetadataExtensionsTest.kt | 2 +- .../prompt/SimpleTemplateRendererTest.kt | 2 +- .../service/ServiceWithPromptTemplatesTest.kt | 2 +- .../ServiceWithSystemMessageProviderTest.kt | 4 +- pom.xml | 15 +++---- 21 files changed, 79 insertions(+), 81 deletions(-) diff --git a/langchain4j-kotlin/pom.xml b/langchain4j-kotlin/pom.xml index 5cefdea..0d07df7 100644 --- a/langchain4j-kotlin/pom.xml +++ b/langchain4j-kotlin/pom.xml @@ -36,11 +36,6 @@ junit-jupiter-api test - - org.jetbrains.kotlinx - kotlinx-coroutines-test-jvm - test - dev.langchain4j langchain4j-open-ai diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/Configuration.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/Configuration.kt index df2dbd5..a085a6a 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/Configuration.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/Configuration.kt @@ -11,14 +11,14 @@ import java.util.Properties * their renderers. The configurations are loaded from a properties file, and components are instantiated dynamically * based on the class names specified in the properties. */ -object Configuration { - val properties: Properties = loadProperties() +public object Configuration { + public val properties: Properties = loadProperties() - operator fun get(key: String): String = properties.getProperty(key) + public operator fun get(key: String): String = properties.getProperty(key) - val promptTemplateSource: PromptTemplateSource = + public val promptTemplateSource: PromptTemplateSource = createInstanceByName(this["prompt.template.source"]) - val promptTemplateRenderer: TemplateRenderer = + public val promptTemplateRenderer: TemplateRenderer = createInstanceByName(this["prompt.template.renderer"]) } diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/TypeAliases.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/TypeAliases.kt index 29fda34..ddb2389 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/TypeAliases.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/TypeAliases.kt @@ -7,7 +7,7 @@ package me.kpavlov.langchain4j.kotlin * and its implementations to specify the input parameter for retrieving * system messages. */ -typealias ChatMemoryId = Any +public typealias ChatMemoryId = Any /** * Type alias for the name of a template. @@ -16,7 +16,7 @@ typealias ChatMemoryId = Any * of the codebase, providing a clearer and more specific meaning compared * to using `String` directly. */ -typealias TemplateName = String +public typealias TemplateName = String /** * Represents the content of a template. @@ -25,7 +25,7 @@ typealias TemplateName = String * which is expected to be in the form of a string. Various classes and functions that deal * with templates will utilize this type alias to ensure consistency and clarity. */ -typealias TemplateContent = String +public typealias TemplateContent = String /** * Type alias for a string representing the content of a prompt. @@ -34,4 +34,4 @@ typealias TemplateContent = String * by various functions and methods within the system that deal with * generating and handling prompts. */ -typealias PromptContent = String +public typealias PromptContent = String diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToReplyFlowAdapter.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToReplyFlowAdapter.kt index ff80071..e381ee6 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToReplyFlowAdapter.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToReplyFlowAdapter.kt @@ -8,14 +8,12 @@ import me.kpavlov.langchain4j.kotlin.model.chat.asReplyFlow import java.lang.reflect.ParameterizedType import java.lang.reflect.Type -class TokenStreamToReplyFlowAdapter : TokenStreamAdapter { +public class TokenStreamToReplyFlowAdapter : TokenStreamAdapter { override fun canAdaptTokenStreamTo(type: Type?): Boolean { - if (type is ParameterizedType) { - if (type.rawType === Flow::class.java) { - val typeArguments: Array = type.actualTypeArguments - return typeArguments.size == 1 && - typeArguments[0] === StreamingChatLanguageModelReply::class.java - } + if (type is ParameterizedType && type.rawType === Flow::class.java) { + val typeArguments: Array = type.actualTypeArguments + return typeArguments.size == 1 && + typeArguments[0] === StreamingChatLanguageModelReply::class.java } return false } diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToStringFlowAdapter.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToStringFlowAdapter.kt index a35fc4d..8041051 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToStringFlowAdapter.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/adapters/TokenStreamToStringFlowAdapter.kt @@ -7,8 +7,8 @@ import me.kpavlov.langchain4j.kotlin.model.chat.asFlow import java.lang.reflect.ParameterizedType import java.lang.reflect.Type -class TokenStreamToStringFlowAdapter : TokenStreamAdapter { - override fun canAdaptTokenStreamTo(type: Type?): Boolean { +public class TokenStreamToStringFlowAdapter : TokenStreamAdapter { + public override fun canAdaptTokenStreamTo(type: Type?): Boolean { if (type is ParameterizedType) { if (type.rawType === Flow::class.java) { val typeArguments: Array = type.actualTypeArguments @@ -18,5 +18,5 @@ class TokenStreamToStringFlowAdapter : TokenStreamAdapter { return false } - override fun adapt(tokenStream: TokenStream): Any = tokenStream.asFlow() + public override fun adapt(tokenStream: TokenStream): Any = tokenStream.asFlow() } diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/ChatLanguageModelExtensions.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/ChatLanguageModelExtensions.kt index d6b67dc..facbc52 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/ChatLanguageModelExtensions.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/ChatLanguageModelExtensions.kt @@ -26,7 +26,7 @@ import me.kpavlov.langchain4j.kotlin.model.chat.request.chatRequest * @see ChatRequest * @see ChatResponse */ -suspend fun ChatLanguageModel.chatAsync(request: ChatRequest): ChatResponse = +public suspend fun ChatLanguageModel.chatAsync(request: ChatRequest): ChatResponse = coroutineScope { this@chatAsync.chat(request) } /** @@ -53,7 +53,7 @@ suspend fun ChatLanguageModel.chatAsync(request: ChatRequest): ChatResponse = * @see ChatRequest.Builder * @see chatAsync */ -suspend fun ChatLanguageModel.chatAsync(requestBuilder: ChatRequest.Builder): ChatResponse = +public suspend fun ChatLanguageModel.chatAsync(requestBuilder: ChatRequest.Builder): ChatResponse = chatAsync(requestBuilder.build()) /** @@ -79,7 +79,7 @@ suspend fun ChatLanguageModel.chatAsync(requestBuilder: ChatRequest.Builder): Ch * associated metadata. * @throws Exception if the chat request fails or encounters an error during execution. */ -suspend fun ChatLanguageModel.chatAsync(block: ChatRequestBuilder.() -> Unit): ChatResponse = +public suspend fun ChatLanguageModel.chatAsync(block: ChatRequestBuilder.() -> Unit): ChatResponse = chatAsync(chatRequest(block)) /** @@ -109,5 +109,5 @@ suspend fun ChatLanguageModel.chatAsync(block: ChatRequestBuilder.() -> Unit): C * @see ChatRequest.Builder * @see ChatRequestBuilder */ -fun ChatLanguageModel.chat(requestBuilder: ChatRequest.Builder): ChatResponse = +public fun ChatLanguageModel.chat(requestBuilder: ChatRequest.Builder): ChatResponse = this.chat(requestBuilder.build()) diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/StreamingChatLanguageModelExtensions.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/StreamingChatLanguageModelExtensions.kt index 6af43bb..a6bd3e2 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/StreamingChatLanguageModelExtensions.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/StreamingChatLanguageModelExtensions.kt @@ -20,7 +20,7 @@ private val logger = LoggerFactory.getLogger(StreamingChatLanguageModel::class.j * Represents different types of replies that can be received from an AI language model during streaming. * This sealed interface provides type-safe handling of both intermediate tokens and final completion responses. */ -sealed interface StreamingChatLanguageModelReply { +public sealed interface StreamingChatLanguageModelReply { /** * Represents a partial response received from an AI language model during a streaming interaction. * @@ -31,7 +31,7 @@ sealed interface StreamingChatLanguageModelReply { * @property token The string representation of the token generated as part of the streaming process. * @see StreamingChatResponseHandler.onPartialResponse */ - data class PartialResponse( + public data class PartialResponse( val token: String, ) : StreamingChatLanguageModelReply @@ -45,7 +45,7 @@ sealed interface StreamingChatLanguageModelReply { * @property response The final chat response generated by the model. * @see StreamingChatResponseHandler.onCompleteResponse */ - data class CompleteResponse( + public data class CompleteResponse( val response: ChatResponse, ) : StreamingChatLanguageModelReply @@ -58,7 +58,7 @@ sealed interface StreamingChatLanguageModelReply { * @property cause The underlying exception or error that caused the failure. * @see StreamingChatResponseHandler.onError */ - data class Error( + public data class Error( val cause: Throwable, ) : StreamingChatLanguageModelReply } @@ -79,7 +79,7 @@ sealed interface StreamingChatLanguageModelReply { * types of replies during the chat interaction, including partial responses, * final responses, and errors. */ -fun StreamingChatLanguageModel.chatFlow( +public fun StreamingChatLanguageModel.chatFlow( block: ChatRequestBuilder.() -> Unit, ): Flow = callbackFlow { @@ -127,7 +127,7 @@ fun StreamingChatLanguageModel.chatFlow( } } -fun TokenStream.asFlow(): Flow = +public fun TokenStream.asFlow(): Flow = flow { callbackFlow { onPartialResponse { trySend(it) } @@ -138,7 +138,7 @@ fun TokenStream.asFlow(): Flow = }.buffer(Channel.UNLIMITED).collect(this) } -fun TokenStream.asReplyFlow(): Flow = +public fun TokenStream.asReplyFlow(): Flow = flow { callbackFlow { onPartialResponse { token -> diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/request/ChatRequestExtensions.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/request/ChatRequestExtensions.kt index 390f18b..4f782d2 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/request/ChatRequestExtensions.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/model/chat/request/ChatRequestExtensions.kt @@ -17,7 +17,7 @@ import dev.langchain4j.model.chat.request.ToolChoice * and/or parameters for the `ChatRequest`. * @return A fully constructed `ChatRequest` instance based on the applied configurations. */ -fun chatRequest(block: ChatRequestBuilder.() -> Unit): ChatRequest { +public fun chatRequest(block: ChatRequestBuilder.() -> Unit): ChatRequest { val builder = ChatRequestBuilder() builder.apply { block() } return builder.build() @@ -44,19 +44,19 @@ fun chatRequest(block: ChatRequestBuilder.() -> Unit): ChatRequest { * @property responseFormat Specifies the format of the response, such as plain text or structured data. */ @Suppress("LongParameterList") -open class ChatRequestParametersBuilder>( - val builder: B, - var modelName: String? = null, - var temperature: Double? = null, - var topP: Double? = null, - var topK: Int? = null, - var frequencyPenalty: Double? = null, - var presencePenalty: Double? = null, - var maxOutputTokens: Int? = null, - var stopSequences: List? = null, - var toolSpecifications: List? = null, - var toolChoice: ToolChoice? = null, - var responseFormat: ResponseFormat? = null, +public open class ChatRequestParametersBuilder>( + public val builder: B, + public var modelName: String? = null, + public var temperature: Double? = null, + public var topP: Double? = null, + public var topK: Int? = null, + public var frequencyPenalty: Double? = null, + public var presencePenalty: Double? = null, + public var maxOutputTokens: Int? = null, + public var stopSequences: List? = null, + public var toolSpecifications: List? = null, + public var toolChoice: ToolChoice? = null, + public var responseFormat: ResponseFormat? = null, ) /** @@ -66,9 +66,9 @@ open class ChatRequestParametersBuilder = mutableListOf(), - var parameters: ChatRequestParameters? = null, +public open class ChatRequestBuilder( + public var messages: MutableList = mutableListOf(), + public var parameters: ChatRequestParameters? = null, ) { /** * Adds a list of `ChatMessage` objects to the builder's messages collection. @@ -76,7 +76,8 @@ open class ChatRequestBuilder( * @param value The list of `ChatMessage` objects to be added to the builder. * @return This builder instance for chaining other method calls. */ - fun messages(value: List) = apply { this.messages.addAll(value) } + public fun messages(value: List): ChatRequestBuilder = + apply { this.messages.addAll(value) } /** * Adds a chat message to the messages list. @@ -84,7 +85,7 @@ open class ChatRequestBuilder( * @param value The chat message to be added. * @return The current instance for method chaining. */ - fun message(value: ChatMessage) = apply { this.messages.add(value) } + public fun message(value: ChatMessage): ChatRequestBuilder = apply { this.messages.add(value) } /** * Builds and returns a ChatRequest instance using the current state of messages and parameters. @@ -106,7 +107,7 @@ open class ChatRequestBuilder( * @param configurer A lambda with the builder as receiver to configure the chat request parameters. */ @JvmOverloads - fun > parameters( + public fun > parameters( @Suppress("UNCHECKED_CAST") builder: B = DefaultChatRequestParameters.builder() as B, configurer: ChatRequestParametersBuilder.() -> Unit, diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplate.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplate.kt index 2f8b6db..0c661de 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplate.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplate.kt @@ -10,7 +10,7 @@ import me.kpavlov.langchain4j.kotlin.TemplateContent * incorporate variables or placeholders. */ public interface PromptTemplate { - fun content(): TemplateContent + public fun content(): TemplateContent } /** @@ -25,5 +25,5 @@ public interface PromptTemplate { public data class SimplePromptTemplate( private val content: TemplateContent, ) : PromptTemplate { - override fun content(): TemplateContent = content + public override fun content(): TemplateContent = content } diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplateSource.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplateSource.kt index 72cd8ed..135c771 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplateSource.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/PromptTemplateSource.kt @@ -9,12 +9,12 @@ import me.kpavlov.langchain4j.kotlin.TemplateName * a template name. The implementation of this interface will determine * how and from where the templates are sourced. */ -interface PromptTemplateSource { +public interface PromptTemplateSource { /** * Retrieves a prompt template based on the provided template name. * * @param name The name of the template to retrieve. * @return The prompt template associated with the specified name, or null if no such template exists. */ - fun getTemplate(name: TemplateName): PromptTemplate? + public fun getTemplate(name: TemplateName): PromptTemplate? } diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/RenderablePromptTemplate.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/RenderablePromptTemplate.kt index 726d5fe..fdee159 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/RenderablePromptTemplate.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/prompt/RenderablePromptTemplate.kt @@ -16,8 +16,8 @@ private val logger = LoggerFactory.getLogger(RenderablePromptTemplate::class.jav * @property content The content of the template. * @property templateRenderer The renderer used for generating the final template string from the content and variables. */ -class RenderablePromptTemplate( - val name: TemplateName, +public class RenderablePromptTemplate( + public val name: TemplateName, private val content: TemplateContent, private val templateRenderer: TemplateRenderer, ) : PromptTemplate, diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/SystemMessageProvider.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/SystemMessageProvider.kt index 92a2064..52c8f31 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/SystemMessageProvider.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/SystemMessageProvider.kt @@ -8,14 +8,14 @@ import java.util.function.Function * Interface for providing LLM system messages based on a given chat memory identifier. */ @FunctionalInterface -interface SystemMessageProvider : Function { +public interface SystemMessageProvider : Function { /** * Provides a system message based on the given chat memory identifier. * * @param chatMemoryID Identifier for the chat memory used to generate the system message. * @return A system prompt string associated with the provided chat memory identifier, maybe `null` */ - fun getSystemMessage(chatMemoryID: ChatMemoryId): PromptContent? + public fun getSystemMessage(chatMemoryID: ChatMemoryId): PromptContent? /** * Applies the given chat memory identifier to generate the corresponding system message. @@ -24,5 +24,6 @@ interface SystemMessageProvider : Function { * @return The prompt content associated with the specified chat memory identifier, * or `null` if no system message is available. */ - override fun apply(chatMemoryID: ChatMemoryId): PromptContent? = getSystemMessage(chatMemoryID) + public override fun apply(chatMemoryID: ChatMemoryId): PromptContent? = + getSystemMessage(chatMemoryID) } diff --git a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/TemplateSystemMessageProvider.kt b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/TemplateSystemMessageProvider.kt index 90ec6e4..1c5ad32 100644 --- a/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/TemplateSystemMessageProvider.kt +++ b/langchain4j-kotlin/src/main/kotlin/me/kpavlov/langchain4j/kotlin/service/TemplateSystemMessageProvider.kt @@ -14,14 +14,14 @@ import me.kpavlov.langchain4j.kotlin.prompt.TemplateRenderer * @property promptTemplateSource Source from which the prompt templates are fetched. * @property promptTemplateRenderer Renderer used to render the content with specific variables. */ -open class TemplateSystemMessageProvider( +public open class TemplateSystemMessageProvider( private val templateName: TemplateName, private val promptTemplateSource: PromptTemplateSource = Configuration.promptTemplateSource, private val promptTemplateRenderer: TemplateRenderer = Configuration.promptTemplateRenderer, ) : SystemMessageProvider { - open fun templateName(): TemplateName = templateName + public open fun templateName(): TemplateName = templateName - constructor( + public constructor( templateName: TemplateName, ) : this( templateName = templateName, diff --git a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/Documents.kt b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/Documents.kt index f4d24a5..c379f41 100644 --- a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/Documents.kt +++ b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/Documents.kt @@ -7,7 +7,7 @@ import me.kpavlov.langchain4j.kotlin.data.document.loadAsync import org.slf4j.Logger import java.nio.file.Paths -suspend fun loadDocument( +public suspend fun loadDocument( documentName: String, logger: Logger, ): Document { diff --git a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/TestEnvironment.kt b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/TestEnvironment.kt index 6840fb3..c883b25 100644 --- a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/TestEnvironment.kt +++ b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/TestEnvironment.kt @@ -2,7 +2,7 @@ package me.kpavlov.langchain4j.kotlin import me.kpavlov.aimocks.openai.MockOpenai -object TestEnvironment : me.kpavlov.finchly.BaseTestEnvironment( +internal object TestEnvironment : me.kpavlov.finchly.BaseTestEnvironment( dotEnvFileDir = "../", ) { val openaiApiKey = get("OPENAI_API_KEY", "demo") diff --git a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/adapters/ServiceWithFlowTest.kt b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/adapters/ServiceWithFlowTest.kt index c3aaef7..8a69895 100644 --- a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/adapters/ServiceWithFlowTest.kt +++ b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/adapters/ServiceWithFlowTest.kt @@ -30,7 +30,7 @@ import org.mockito.kotlin.doAnswer import org.mockito.kotlin.whenever @ExtendWith(MockitoExtension::class) -class ServiceWithFlowTest { +internal class ServiceWithFlowTest { @Mock private lateinit var model: StreamingChatLanguageModel diff --git a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/data/document/MetadataExtensionsTest.kt b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/data/document/MetadataExtensionsTest.kt index d4a1793..20a9d54 100644 --- a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/data/document/MetadataExtensionsTest.kt +++ b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/data/document/MetadataExtensionsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock -class MetadataExtensionsTest { +internal class MetadataExtensionsTest { @Test fun `merge should combine unique metadata from both objects`() { val metadata1 = diff --git a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/prompt/SimpleTemplateRendererTest.kt b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/prompt/SimpleTemplateRendererTest.kt index 2d5f43d..6a2bbc4 100644 --- a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/prompt/SimpleTemplateRendererTest.kt +++ b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/prompt/SimpleTemplateRendererTest.kt @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -class SimpleTemplateRendererTest { +internal class SimpleTemplateRendererTest { private val subject = SimpleTemplateRenderer() @Test diff --git a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithPromptTemplatesTest.kt b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithPromptTemplatesTest.kt index 88d52df..67f1f22 100644 --- a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithPromptTemplatesTest.kt +++ b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithPromptTemplatesTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith import org.mockito.junit.jupiter.MockitoExtension @ExtendWith(MockitoExtension::class) -class ServiceWithPromptTemplatesTest { +internal class ServiceWithPromptTemplatesTest { private lateinit var model: ChatLanguageModel @Test diff --git a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithSystemMessageProviderTest.kt b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithSystemMessageProviderTest.kt index 78382c2..a09f9f0 100644 --- a/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithSystemMessageProviderTest.kt +++ b/langchain4j-kotlin/src/test/kotlin/me/kpavlov/langchain4j/kotlin/service/ServiceWithSystemMessageProviderTest.kt @@ -10,10 +10,12 @@ import dev.langchain4j.service.AiServices import dev.langchain4j.service.UserMessage import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension @ExtendWith(MockitoExtension::class) -class ServiceWithSystemMessageProviderTest { +internal class ServiceWithSystemMessageProviderTest { + @Mock lateinit var model: ChatLanguageModel @Test diff --git a/pom.xml b/pom.xml index a2e54c3..a658bca 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ - + UTF-8 official 17 @@ -156,7 +156,7 @@ org.jetbrains.kotlinx - kotlinx-coroutines-test + kotlinx-coroutines-test-jvm test @@ -209,8 +209,7 @@ com.github.ozsie detekt-maven-plugin 1.23.8 - - + org.jetbrains.kotlinx @@ -247,17 +246,17 @@ origin/main - + - + **/*.md - + @@ -279,6 +278,8 @@ -Werror + -Wextra + -Xexplicit-api=strict -Xjspecify-annotations=strict -Xjsr305=strict -Xtype-enhancement-improvements-strict-mode