Skip to content

Commit

Permalink
feat: LangChain4j support
Browse files Browse the repository at this point in the history
  • Loading branch information
xmxnt committed Dec 17, 2024
1 parent c9e04e1 commit ca91930
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class LangChainChatModelFactory private constructor() {
fun createClient(properties: ModelClientProperties): ChatLanguageModel {
return when (properties.provider) {
LangChainClientProvider.OPENAI.name.lowercase(),
LangChainClientProvider.GROQ.name.lowercase(),
LangChainClientProvider.OTHER.name.lowercase(),
-> {
OpenAiChatModelBuilder().baseUrl(properties.url)
Expand Down Expand Up @@ -114,6 +113,5 @@ enum class LangChainClientProvider {
ANTHROPIC,
GEMINI,
OLLAMA,
GROQ,
OTHER,
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LangChainChatModelFactoryTest {
every { properties.temperature } returns 0.7
every { properties.topP } returns 0.9
every { properties.topK } returns 50
every { properties.format } returns "json"
every { properties.format } returns "json_object"

// Act
val client = LangChainChatModelFactory.createClient(properties)
Expand Down Expand Up @@ -105,27 +105,6 @@ class LangChainChatModelFactoryTest {
assertTrue(client is OllamaChatModel)
}

@Test
fun `createClient should return OpenAiChatModel for GROQ provider`() {
// Arrange
val properties = mockk<ModelClientProperties>()
every { properties.provider } returns LangChainClientProvider.GROQ.name.lowercase()
every { properties.url } returns "https://api.groq.com"
every { properties.apiKey } returns "groq-api-key"
every { properties.model } returns "groq-model"
every { properties.maxTokens } returns 1200
every { properties.temperature } returns 0.65
every { properties.topP } returns 0.75
every { properties.topK } returns 45
every { properties.format } returns "xml"

// Act
val client = LangChainChatModelFactory.createClient(properties)

// Assert
assertTrue(client is OpenAiChatModel)
}

@Test
fun `createClient should return OpenAiChatModel for OTHER provider`() {
// Arrange
Expand All @@ -138,7 +117,7 @@ class LangChainChatModelFactoryTest {
every { properties.temperature } returns 0.8
every { properties.topP } returns 0.95
every { properties.topK } returns 60
every { properties.format } returns "markdown"
every { properties.format } returns "json_object"

// Act
val client = LangChainChatModelFactory.createClient(properties)
Expand Down

0 comments on commit ca91930

Please sign in to comment.