Ollama4j
A Java library (wrapper/binding) for Ollama server.
|
Public Member Functions | |
PromptBuilder () | |
PromptBuilder | add (String text) |
PromptBuilder | addLine (String text) |
PromptBuilder | addSeparator () |
String | build () |
The PromptBuilder
class is used to construct prompt texts for language models (LLMs). It provides methods for adding text, adding lines, adding separators, and building the final prompt.
Example usage:
PromptBuilder promptBuilder = new PromptBuilder();
promptBuilder.add("This is a sample prompt for language models.")
.addLine("You can add lines to provide context.")
.addSeparator()
.add("Feel free to customize as needed.");
String finalPrompt = promptBuilder.build();
System.out.println(finalPrompt);
Definition at line 19 of file PromptBuilder.java.
io.github.ollama4j.utils.PromptBuilder.PromptBuilder | ( | ) |
Constructs a new PromptBuilder
with an empty prompt.
Definition at line 24 of file PromptBuilder.java.
PromptBuilder io.github.ollama4j.utils.PromptBuilder.add | ( | String | text | ) |
Appends the specified text to the prompt.
text | the text to be added to the prompt |
PromptBuilder
instance for method chaining Definition at line 34 of file PromptBuilder.java.
PromptBuilder io.github.ollama4j.utils.PromptBuilder.addLine | ( | String | text | ) |
Appends the specified text followed by a newline character to the prompt.
text | the text to be added as a line to the prompt |
PromptBuilder
instance for method chaining Definition at line 45 of file PromptBuilder.java.
PromptBuilder io.github.ollama4j.utils.PromptBuilder.addSeparator | ( | ) |
Appends a separator line to the prompt. The separator is a newline followed by a line of dashes.
PromptBuilder
instance for method chaining Definition at line 56 of file PromptBuilder.java.
String io.github.ollama4j.utils.PromptBuilder.build | ( | ) |
Builds and returns the final prompt as a string.
Definition at line 66 of file PromptBuilder.java.