Use Double instead of Float for portable ChatOptions
This change updates the type of portable chat options from Float to Double. Affected options include: - frequencyPenalty - presencePenalty - temperature - topP The motivation for this change is to simplify coding. In Java, Float values require an "f" suffix (e.g., 0.5f), while Double values don't need any suffix. This makes Double easier to type and reduces potential errors from forgetting the "f" suffix. APIs, tests, and documentation have been updated to reflect this change. Fixes gh-712 Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
This commit is contained in:
committed by
Mark Pollack
parent
40714c984d
commit
4b123a7516
@@ -40,8 +40,8 @@ public class ChatBuilderTests {
|
||||
|
||||
@Test
|
||||
void createNewChatOptionsTest() {
|
||||
Float temperature = 1.1f;
|
||||
Float topP = 2.2f;
|
||||
Double temperature = 1.1;
|
||||
Double topP = 2.2;
|
||||
Integer topK = 111;
|
||||
|
||||
ChatOptions options = ChatOptionsBuilder.builder()
|
||||
@@ -57,8 +57,8 @@ public class ChatBuilderTests {
|
||||
|
||||
@Test
|
||||
void duplicateChatOptionsTest() {
|
||||
Float initTemperature = 1.1f;
|
||||
Float initTopP = 2.2f;
|
||||
Double initTemperature = 1.1;
|
||||
Double initTopP = 2.2;
|
||||
Integer initTopK = 111;
|
||||
|
||||
ChatOptions options = ChatOptionsBuilder.builder()
|
||||
@@ -71,8 +71,8 @@ public class ChatBuilderTests {
|
||||
|
||||
@Test
|
||||
void createFunctionCallingOptionTest() {
|
||||
Float temperature = 1.1f;
|
||||
Float topP = 2.2f;
|
||||
Double temperature = 1.1;
|
||||
Double topP = 2.2;
|
||||
Integer topK = 111;
|
||||
List<FunctionCallback> functionCallbacks = new ArrayList<>();
|
||||
Set<String> functions = new HashSet<>();
|
||||
|
||||
@@ -98,13 +98,13 @@ class DefaultChatModelObservationConventionTests {
|
||||
.provider("superprovider")
|
||||
.requestOptions(ChatOptionsBuilder.builder()
|
||||
.withModel("mistral")
|
||||
.withFrequencyPenalty(0.8f)
|
||||
.withFrequencyPenalty(0.8)
|
||||
.withMaxTokens(200)
|
||||
.withPresencePenalty(1.0f)
|
||||
.withPresencePenalty(1.0)
|
||||
.withStopSequences(List.of("addio", "bye"))
|
||||
.withTemperature(0.5f)
|
||||
.withTemperature(0.5)
|
||||
.withTopK(1)
|
||||
.withTopP(0.9f)
|
||||
.withTopP(0.9)
|
||||
.build())
|
||||
.build();
|
||||
observationContext.setResponse(new ChatResponse(
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PromptTemplateTest {
|
||||
public void testCreateWithEmptyModelAndChatOptions() {
|
||||
String template = "This is a test prompt with no variables";
|
||||
PromptTemplate promptTemplate = new PromptTemplate(template);
|
||||
ChatOptions chatOptions = ChatOptionsBuilder.builder().withTemperature(0.7f).withTopK(3).build();
|
||||
ChatOptions chatOptions = ChatOptionsBuilder.builder().withTemperature(0.7).withTopK(3).build();
|
||||
|
||||
Prompt prompt = promptTemplate.create(chatOptions);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PromptTemplateTest {
|
||||
model.put("name", "Alice");
|
||||
model.put("age", 30);
|
||||
PromptTemplate promptTemplate = new PromptTemplate(template, model);
|
||||
ChatOptions chatOptions = ChatOptionsBuilder.builder().withTemperature(0.5f).withMaxTokens(100).build();
|
||||
ChatOptions chatOptions = ChatOptionsBuilder.builder().withTemperature(0.5).withMaxTokens(100).build();
|
||||
|
||||
Prompt prompt = promptTemplate.create(model, chatOptions);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class PromptTemplateTest {
|
||||
|
||||
Map<String, Object> overriddenModel = new HashMap<>();
|
||||
overriddenModel.put("color", "red");
|
||||
ChatOptions chatOptions = ChatOptionsBuilder.builder().withTemperature(0.8f).build();
|
||||
ChatOptions chatOptions = ChatOptionsBuilder.builder().withTemperature(0.8).build();
|
||||
|
||||
Prompt prompt = promptTemplate.create(overriddenModel, chatOptions);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user