The OllamaService interface provide the interaction with the ollama web service.
public interface OllamaService {
CompletionResponse completion(CompletionRequest completionRequest);
TagsResponse getTags();
ShowResponse show(ShowRequest showRequest);
void copy(CopyRequest copyRequest);
void delete(String modelName);
void streamingCompletion(CompletionRequest completionRequest, StreamResponseProcessor<String> handler);
EmbeddingResponse embed(EmbeddingRequest embeddingRequest);
}
The OllamaServiceFactory class is responsible for creating
instances of the OllamaService
. It provides builder methods
to create an instance of the service with the specified configuration.
public class OllamaServiceFactory {
public static OllamaService create(OllamaProperties properties) { // ...
}
public static OllamaService create(OllamaProperties properties, Gson gson) { // ...
}
}
The StreamResponseProcessor interface provides methods to process streaming completion responses.
public interface StreamResponseProcessor<T> {
void processStreamItem(T item);
void processCompletion(T fullResponse);
void processError(Throwable throwable);
}