Skip to content

Commit

Permalink
Merge pull request #276 from johnoliver/fix-java-types
Browse files Browse the repository at this point in the history
Fix java types
  • Loading branch information
johnoliver authored Dec 5, 2024
2 parents cf3d8cf + f59e19c commit 7655593
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.4.2

- Fix bug effecting using native Java methods with OpenAI tool calling

# 1.4.1

- Add Otel Telemetry on function invocations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,30 @@ private static String getSchemaForFunctionParameter(@Nullable InputVariable para

private static String getJavaTypeToOpenAiFunctionType(String javaType) {
switch (javaType.toLowerCase(Locale.ROOT)) {
case "java.lang.boolean":
case "boolean":
return "boolean";
case "java.lang.integer":
case "integer":
case "int":
case "java.lang.long":
case "long":
case "java.lang.short":
case "short":
case "java.lang.byte":
case "byte":
return "integer";
case "java.lang.double":
case "double":
case "java.lang.float":
case "float":
return "number";
case "java.lang.string":
case "string":
return "string";
case "array":
return "array";
case "java.lang.void":
case "void":
return "null";
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ static ChatCompletionsOptions cloneOptionsWithMessages(
.setN(options.getN())
.setResponseFormat(options.getResponseFormat())
.setSeed(options.getSeed())
.setStream(options.isStream())
.setToolChoice(options.getToolChoice());
.setStream(options.isStream());

if (options.getToolChoice() != null) {
newOptions.setToolChoice(options.getToolChoice());
}

if (options.getFunctionCall() != null) {
newOptions = newOptions.setFunctionCall(options.getFunctionCall());
Expand Down

0 comments on commit 7655593

Please sign in to comment.