Skip to content

Commit 12387ec

Browse files
committed
- move fallback chat model to internal package
1 parent f2b71b4 commit 12387ec

7 files changed

Lines changed: 15 additions & 24 deletions

File tree

modules/jooby-langchain4j/src/main/java/io/jooby/langchain4j/FallbackChatModel.java renamed to modules/jooby-langchain4j/src/main/java/io/jooby/internal/langchain4j/FallbackChatModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
44
* Copyright 2014 Edgar Espina
55
*/
6-
package io.jooby.langchain4j;
6+
package io.jooby.internal.langchain4j;
77

88
import dev.langchain4j.model.chat.ChatModel;
99
import dev.langchain4j.model.chat.request.ChatRequest;
1010
import dev.langchain4j.model.chat.response.ChatResponse;
11+
import io.jooby.langchain4j.FailoverListener;
1112

1213
/**
1314
* Decorator for {@link ChatModel} that provides failover logic. Catching exceptions from the

modules/jooby-langchain4j/src/main/java/io/jooby/langchain4j/FallbackStreamingChatModel.java renamed to modules/jooby-langchain4j/src/main/java/io/jooby/internal/langchain4j/FallbackStreamingChatModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
44
* Copyright 2014 Edgar Espina
55
*/
6-
package io.jooby.langchain4j;
6+
package io.jooby.internal.langchain4j;
77

88
import dev.langchain4j.model.chat.StreamingChatModel;
99
import dev.langchain4j.model.chat.request.ChatRequest;
1010
import dev.langchain4j.model.chat.response.StreamingChatResponseHandler;
11+
import io.jooby.langchain4j.FailoverListener;
1112

1213
/**
1314
* Decorator for {@link StreamingChatModel} handling asynchronous failover. Fallback triggers only

modules/jooby-langchain4j/src/main/java/io/jooby/langchain4j/LangChain4jModule.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
import io.jooby.Jooby;
1616
import io.jooby.ServiceKey;
1717
import io.jooby.internal.langchain4j.BuiltInModel;
18+
import io.jooby.internal.langchain4j.FallbackChatModel;
19+
import io.jooby.internal.langchain4j.FallbackStreamingChatModel;
1820

1921
/**
2022
* Jooby Extension for LangChain4j.
2123
*
2224
* <p>This module provides seamless integration between Jooby and the LangChain4j 1.x ecosystem,
2325
* automatically instantiating and registering {@link dev.langchain4j.model.chat.ChatModel} and
2426
* {@link dev.langchain4j.model.chat.StreamingChatModel} components based on your application
25-
* configuration. *
27+
* configuration.
2628
*
2729
* <h3>Installation</h3>
2830
*
@@ -38,8 +40,6 @@
3840
* }
3941
* }</pre>
4042
*
41-
* *
42-
*
4343
* <h3>Configuration</h3>
4444
*
4545
* <p>Models are defined in your {@code application.conf} under the {@code langchain4j.models} key.
@@ -61,8 +61,6 @@
6161
* }
6262
* }</pre>
6363
*
64-
* *
65-
*
6664
* <h3>Resilience & Fallback Routing</h3>
6765
*
6866
* <p>You can define a chain of fallbacks to ensure high availability. If the primary model fails
@@ -76,7 +74,7 @@
7674
* api-key = "..."
7775
* fallback = ["local-failover"]
7876
* }
79-
* * local-failover {
77+
* local-failover {
8078
* provider = "jlama"
8179
* model-name = "tjake/Llama-3.2-1B-Instruct-JQ4"
8280
* }
@@ -93,8 +91,6 @@
9391
* );
9492
* }</pre>
9593
*
96-
* *
97-
*
9894
* <h3>Custom Providers</h3>
9995
*
10096
* <p>The extension includes built-in support for popular providers like OpenAI, Anthropic, Ollama,
@@ -115,8 +111,6 @@
115111
* );
116112
* }</pre>
117113
*
118-
* *
119-
*
120114
* <h3>Dependency Management</h3>
121115
*
122116
* <p>To keep your application lightweight, the heavy provider SDKs (like {@code

modules/jooby-langchain4j/src/main/java/io/jooby/langchain4j/package-info.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* <p>This module provides seamless integration between Jooby and the LangChain4j 1.x ecosystem,
55
* automatically instantiating and registering {@link dev.langchain4j.model.chat.ChatModel} and
66
* {@link dev.langchain4j.model.chat.StreamingChatModel} components based on your application
7-
* configuration. *
7+
* configuration.
88
*
99
* <h3>Installation</h3>
1010
*
@@ -20,8 +20,6 @@
2020
* }
2121
* }</pre>
2222
*
23-
* *
24-
*
2523
* <h3>Configuration</h3>
2624
*
2725
* <p>Models are defined in your {@code application.conf} under the {@code langchain4j.models} key.
@@ -43,8 +41,6 @@
4341
* }
4442
* }</pre>
4543
*
46-
* *
47-
*
4844
* <h3>Resilience & Fallback Routing</h3>
4945
*
5046
* <p>You can define a chain of fallbacks to ensure high availability. If the primary model fails
@@ -58,7 +54,7 @@
5854
* api-key = "..."
5955
* fallback = ["local-failover"]
6056
* }
61-
* * local-failover {
57+
* local-failover {
6258
* provider = "jlama"
6359
* model-name = "tjake/Llama-3.2-1B-Instruct-JQ4"
6460
* }
@@ -75,8 +71,6 @@
7571
* );
7672
* }</pre>
7773
*
78-
* *
79-
*
8074
* <h3>Custom Providers</h3>
8175
*
8276
* <p>The extension includes built-in support for popular providers like OpenAI, Anthropic, Ollama,
@@ -97,8 +91,6 @@
9791
* );
9892
* }</pre>
9993
*
100-
* *
101-
*
10294
* <h3>Dependency Management</h3>
10395
*
10496
* <p>To keep your application lightweight, the heavy provider SDKs (like {@code

modules/jooby-langchain4j/src/test/java/io/jooby/langchain4j/FallbackChatModelTest.java renamed to modules/jooby-langchain4j/src/test/java/io/jooby/internal/langchain4j/FallbackChatModelTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
44
* Copyright 2014 Edgar Espina
55
*/
6-
package io.jooby.langchain4j;
6+
package io.jooby.internal.langchain4j;
77

88
import static org.junit.jupiter.api.Assertions.assertEquals;
99
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -16,6 +16,7 @@
1616
import dev.langchain4j.model.chat.ChatModel;
1717
import dev.langchain4j.model.chat.request.ChatRequest;
1818
import dev.langchain4j.model.chat.response.ChatResponse;
19+
import io.jooby.langchain4j.FailoverListener;
1920

2021
class FallbackChatModelTest {
2122

modules/jooby-langchain4j/src/test/java/io/jooby/langchain4j/FallbackStreamingChatModelTest.java renamed to modules/jooby-langchain4j/src/test/java/io/jooby/internal/langchain4j/FallbackStreamingChatModelTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
44
* Copyright 2014 Edgar Espina
55
*/
6-
package io.jooby.langchain4j;
6+
package io.jooby.internal.langchain4j;
77

88
import static org.mockito.Mockito.*;
99

@@ -15,6 +15,7 @@
1515
import dev.langchain4j.model.chat.request.ChatRequest;
1616
import dev.langchain4j.model.chat.response.ChatResponse;
1717
import dev.langchain4j.model.chat.response.StreamingChatResponseHandler;
18+
import io.jooby.langchain4j.FailoverListener;
1819

1920
class FallbackStreamingChatModelTest {
2021

modules/jooby-langchain4j/src/test/java/io/jooby/langchain4j/LangChain4jModuleTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.jooby.Jooby;
2323
import io.jooby.ServiceKey;
2424
import io.jooby.ServiceRegistry;
25+
import io.jooby.internal.langchain4j.FallbackChatModel;
2526

2627
class LangChain4jModuleTest {
2728

0 commit comments

Comments
 (0)