Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
SamplePrompts.java
Go to the documentation of this file.
1package io.github.ollama4j.utils;
2
3import io.github.ollama4j.OllamaAPI;
4
5import java.io.InputStream;
6import java.util.Scanner;
7
8public class SamplePrompts {
9 public static String getSampleDatabasePromptWithQuestion(String question) throws Exception {
10 ClassLoader classLoader = OllamaAPI.class.getClassLoader();
11 InputStream inputStream = classLoader.getResourceAsStream("sample-db-prompt-template.txt");
12 if (inputStream != null) {
13 Scanner scanner = new Scanner(inputStream);
14 StringBuilder stringBuffer = new StringBuilder();
15 while (scanner.hasNextLine()) {
16 stringBuffer.append(scanner.nextLine()).append("\n");
17 }
18 scanner.close();
19 return stringBuffer.toString().replaceAll("<question>", question);
20 } else {
21 throw new Exception("Sample database question file not found.");
22 }
23 }
24
25}
static String getSampleDatabasePromptWithQuestion(String question)