Skip to content

Commit 03099f7

Browse files
committed
[watsonx.ai] Add time_limit parameter
1 parent e812cb3 commit 03099f7

File tree

6 files changed

+18
-0
lines changed

6 files changed

+18
-0
lines changed

model-providers/watsonx/deployment/src/test/java/io/quarkiverse/langchain4j/watsonx/deployment/AllPropertiesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void handlerBeforeEach() {
9898
.randomSeed(2)
9999
.stopSequences(List.of("\n", "\n\n"))
100100
.temperature(1.5)
101+
.timeLimit(60000L)
101102
.topK(90)
102103
.topP(0.5)
103104
.repetitionPenalty(2.0)

model-providers/watsonx/deployment/src/test/java/io/quarkiverse/langchain4j/watsonx/deployment/DefaultPropertiesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void handlerBeforeEach() {
5858
.maxNewTokens(200)
5959
.decodingMethod("greedy")
6060
.temperature(1.0)
61+
.timeLimit(10000L)
6162
.build();
6263

6364
@Inject

model-providers/watsonx/runtime/src/main/java/io/quarkiverse/langchain4j/watsonx/WatsonxChatModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private Parameters createParameters() {
108108
.randomSeed(randomSeed)
109109
.stopSequences(stopSequences)
110110
.temperature(temperature)
111+
.timeLimit(timeLimit)
111112
.topP(topP)
112113
.topK(topK)
113114
.repetitionPenalty(repetitionPenalty)

model-providers/watsonx/runtime/src/main/java/io/quarkiverse/langchain4j/watsonx/WatsonxModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public abstract class WatsonxModel {
3737
final Integer randomSeed;
3838
final List<String> stopSequences;
3939
final Double temperature;
40+
final Long timeLimit;
4041
final Double topP;
4142
final Integer topK;
4243
final Double repetitionPenalty;
@@ -72,6 +73,7 @@ public WatsonxModel(Builder builder) {
7273
this.randomSeed = builder.randomSeed;
7374
this.stopSequences = builder.stopSequences;
7475
this.temperature = builder.temperature;
76+
this.timeLimit = builder.timeout.toMillis();
7577
this.topP = builder.topP;
7678
this.topK = builder.topK;
7779
this.repetitionPenalty = builder.repetitionPenalty;

model-providers/watsonx/runtime/src/main/java/io/quarkiverse/langchain4j/watsonx/WatsonxStreamingChatModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void generate(List<ChatMessage> messages, StreamingResponseHandler<AiMess
4343
.randomSeed(randomSeed)
4444
.stopSequences(stopSequences)
4545
.temperature(temperature)
46+
.timeLimit(timeLimit)
4647
.topP(topP)
4748
.topK(topK)
4849
.repetitionPenalty(repetitionPenalty)

model-providers/watsonx/runtime/src/main/java/io/quarkiverse/langchain4j/watsonx/bean/Parameters.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public record LengthPenalty(Double decayFactor, Integer startIndex) {
1414
private final Integer randomSeed;
1515
private final List<String> stopSequences;
1616
private final Double temperature;
17+
private final Long timeLimit;
1718
private final Integer topK;
1819
private final Double topP;
1920
private final Double repetitionPenalty;
@@ -28,6 +29,7 @@ private Parameters(Builder builder) {
2829
this.randomSeed = builder.randomSeed;
2930
this.stopSequences = builder.stopSequences;
3031
this.temperature = builder.temperature;
32+
this.timeLimit = builder.timeLimit;
3133
this.topK = builder.topK;
3234
this.topP = builder.topP;
3335
this.repetitionPenalty = builder.repetitionPenalty;
@@ -59,6 +61,10 @@ public Double getTemperature() {
5961
return temperature;
6062
}
6163

64+
public Long getTimeLimit() {
65+
return timeLimit;
66+
}
67+
6268
public Integer getRandomSeed() {
6369
return randomSeed;
6470
}
@@ -96,6 +102,7 @@ public static class Builder {
96102
private Integer randomSeed;
97103
private List<String> stopSequences;
98104
private Double temperature;
105+
private Long timeLimit;
99106
private Integer topK;
100107
private Double topP;
101108
private Double repetitionPenalty;
@@ -127,6 +134,11 @@ public Builder temperature(Double temperature) {
127134
return this;
128135
}
129136

137+
public Builder timeLimit(Long timeLimit) {
138+
this.timeLimit = timeLimit;
139+
return this;
140+
}
141+
130142
public Builder randomSeed(Integer randomSeed) {
131143
this.randomSeed = randomSeed;
132144
return this;

0 commit comments

Comments
 (0)