You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now you could inject the OllamaService bean in any bean of your application:
@BeanApplicationRunnerrunner(OllamaServiceollamaService,SimpleStringStreamResponseProcessorstreamResponseProcessor){
returnargs->{
// Embedding requestEmbeddingResponseembeddingResponse=ollamaService.embed(EmbeddingRequest.builder()
.model(MODEL_NAME)
.prompt("Dare to embed this text?")
.build());
log.info("******* Ollama Embedding response: {}",embeddingResponse.getEmbedding());
log.info("******* (wait for it)");
// Completion requestArrays.asList("What is the capital city of Spain?",
"Translate this text to Spanish: 'I love cookies!'")
.forEach(prompt->{
CompletionResponseresponse=ollamaService.completion(CompletionRequest.builder()
.model(MODEL_NAME).prompt(prompt).build());
log.info("******* Ollama Completion response: {}",response.getResponse());
});
// Streaming completionollamaService.streamingCompletion(CompletionRequest.builder()
.model(MODEL_NAME)
.prompt("What is the meaning of life?")
.build(),streamResponseProcessor);
};
}
Run it:
Install Ollama and the Mistral 7b model as stated here and run the application: