Skip to content

Commit

Permalink
Update apps to latest Spring AI + Upgrade to Gradle 8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVitale committed Aug 14, 2024
1 parent 3228023 commit 71a0aa0
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ArtistInfo chatWithBeanOutput(MusicQuestion question) {
.param("instrument", question.instrument())
)
.options(OpenAiChatOptions.builder()
.withResponseFormat(new OpenAiApi.ChatCompletionRequest.ResponseFormat("json_object"))
.withResponseFormat(new OpenAiApi.ChatCompletionRequest.ResponseFormat(OpenAiApi.ChatCompletionRequest.ResponseFormat.Type.JSON_OBJECT))
.build())
.call()
.entity(ArtistInfo.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class EmbeddingController {
@GetMapping("/embed")
String embed(@RequestParam(defaultValue = "And Gandalf yelled: 'You shall not pass!'") String message) {
var embeddings = embeddingModel.embed(message);
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

@GetMapping("/embed/mistral-ai-options")
Expand All @@ -30,7 +30,7 @@ String embedWithMistralAiOptions(@RequestParam(defaultValue = "And Gandalf yelle
.withModel("mistral-embed")
.build()))
.getResult().getOutput();
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class EmbeddingController {
@GetMapping("/embed")
String embed(@RequestParam(defaultValue = "And Gandalf yelled: 'You shall not pass!'") String message) {
var embeddings = embeddingModel.embed(message);
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

@GetMapping("/embed/ollama-options")
String embedWithOllamaOptions(@RequestParam(defaultValue = "And Gandalf yelled: 'You shall not pass!'") String message) {
var embeddings = embeddingModel.call(new EmbeddingRequest(List.of(message), OllamaOptions.create()
.withModel("mistral")))
.getResult().getOutput();
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class EmbeddingController {
@GetMapping("/embed")
String embed(@RequestParam(defaultValue = "And Gandalf yelled: 'You shall not pass!'") String message) {
var embeddings = embeddingModel.embed(message);
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

@GetMapping("/embed/openai-options")
Expand All @@ -31,7 +31,7 @@ String embedWithOpenAiOptions(@RequestParam(defaultValue = "And Gandalf yelled:
.withUser("jon.snow")
.build()))
.getResult().getOutput();
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EmbeddingController {
@GetMapping("/embed")
String embed(@RequestParam(defaultValue = "And Gandalf yelled: 'You shall not pass!'") String message) {
var embeddings = embeddingModel.embed(message);
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class EmbeddingController {
@GetMapping("/embed")
String embed(@RequestParam(defaultValue = "And Gandalf yelled: 'You shall not pass!'") String message) {
var embeddings = embeddingModel.embed(message);
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

@GetMapping("/embed/openai-options")
Expand All @@ -31,7 +31,7 @@ String embedWithOpenAiOptions(@RequestParam(defaultValue = "And Gandalf yelled:
.withEncodingFormat("float")
.build()))
.getResult().getOutput();
return "Size of the embedding vector: " + embeddings.size();
return "Size of the embedding vector: " + embeddings.length;
}

}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down

0 comments on commit 71a0aa0

Please sign in to comment.