Skip to content

Commit

Permalink
Update Ollama + Hugging Face example
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVitale committed Oct 22, 2024
1 parent 1f1e427 commit 0b6816f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.prompt.ChatOptionsBuilder;
import org.springframework.ai.ollama.api.OllamaOptions;
import org.springframework.ai.ollama.management.PullModelStrategy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -57,7 +56,6 @@ String chatWithHuggingFace(@RequestParam(defaultValue = "What did Gandalf say to
.prompt(question)
.options(OllamaOptions.create()
.withModel("hf.co/SanctumAI/Llama-3.2-1B-Instruct-GGUF")
.withPullModelStrategy(PullModelStrategy.WHEN_MISSING)
.build())
.call()
.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.springframework.ai.chat.prompt.ChatOptionsBuilder;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.ollama.api.OllamaOptions;
import org.springframework.ai.ollama.management.PullModelStrategy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -49,7 +48,6 @@ String chatWithProviderOptions(@RequestParam(defaultValue = "What did Gandalf sa
String chatWithHuggingFace(@RequestParam(defaultValue = "What did Gandalf say to the Balrog?") String question) {
return chatModel.call(new Prompt(question, OllamaOptions.builder()
.withModel("hf.co/SanctumAI/Llama-3.2-1B-Instruct-GGUF")
.withPullModelStrategy(PullModelStrategy.WHEN_MISSING)
.build()))
.getResult().getOutput().getContent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ spring:
ollama:
init:
pull-model-strategy: when_missing
chat:
additional-models:
- hf.co/SanctumAI/Llama-3.2-1B-Instruct-GGUF
embedding:
include: false
chat:
Expand Down

0 comments on commit 0b6816f

Please sign in to comment.