Package org.odinware.odinrunes
Class OllamaWellsOfWisdom
java.lang.Object
org.odinware.odinrunes.OllamaWellsOfWisdom
- All Implemented Interfaces:
WellsOfWisdom
The
OllamaWellsOfWisdom
class is responsible for constructing a valid HTTP request
to the Ollama API for chat completions.
It implements the WellsOfWisdom
interface.
Before building the request, it takes a provided context, messages, and GPT settings, and constructs a JSON payload with the appropriate format required by the Ollama API.
Once the request is built, it includes the appropriate headers and authentication information. It returns the constructed request object.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionokhttp3.Request
buildRequest
(Context context, org.json.JSONArray odinMessages, org.json.JSONObject gptSettingsJsonObject) Constructs an HTTP request to the Ollama API using the provided context and messages.okhttp3.Response
executeRequest
(okhttp3.Request request) Executes a HTTP request and returns the Response object.readFromResponseStream
(okhttp3.Response response) Reads from the Response object.
-
Constructor Details
-
OllamaWellsOfWisdom
public OllamaWellsOfWisdom()
-
-
Method Details
-
buildRequest
public okhttp3.Request buildRequest(Context context, org.json.JSONArray odinMessages, org.json.JSONObject gptSettingsJsonObject) throws Exception Constructs an HTTP request to the Ollama API using the provided context and messages.- Specified by:
buildRequest
in interfaceWellsOfWisdom
- Parameters:
context
- The context containing captured data.odinMessages
- The messages exchanged between the user and the assistant.gptSettingsJsonObject
- The settings for the GPT model.- Returns:
- A built HTTP request object, or null if no new prompt is present.
- Throws:
Exception
- If there is an error while building the request.
-
executeRequest
public okhttp3.Response executeRequest(okhttp3.Request request) Description copied from interface:WellsOfWisdom
Executes a HTTP request and returns the Response object.- Specified by:
executeRequest
in interfaceWellsOfWisdom
- Parameters:
request
- The context containing captured data and user options.- Returns:
- A built HTTP response object, or null if no response.
-
readFromResponseStream
Description copied from interface:WellsOfWisdom
Reads from the Response object.- Specified by:
readFromResponseStream
in interfaceWellsOfWisdom
- Parameters:
response
- The response object.- Returns:
- A string generated by the gpt provider and read from the HTTP response object.
-