Package org.odinware.odinrunes
Class GoogleGeminiWellsOfWisdomOverVertexAI
java.lang.Object
org.odinware.odinrunes.GoogleGeminiWellsOfWisdomOverVertexAI
- All Implemented Interfaces:
WellsOfWisdom
The
GoogleGeminiWellsOfWisdomOverVertexAI class is responsible for constructing a valid HTTP request
to the Google Gemini API via GCP's VertexAI 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 Gemini API.
Once the request is built, it includes the appropriate headers and temporary access token. It returns the constructed request object.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionokhttp3.RequestbuildRequest(Context context, org.json.JSONArray odinMessages, org.json.JSONObject gptSettingsJsonObject) Constructs an HTTP request to the Google Gemini API via GCP's VertexAI using the provided context and messages.okhttp3.ResponseexecuteRequest(okhttp3.Request request) Executes a HTTP request and returns the Response object.readFromResponseStream(okhttp3.Response response) Reads from the Response object.
-
Constructor Details
-
GoogleGeminiWellsOfWisdomOverVertexAI
public GoogleGeminiWellsOfWisdomOverVertexAI()
-
-
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 Google Gemini API via GCP's VertexAI using the provided context and messages.- Specified by:
buildRequestin 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) Executes a HTTP request and returns the Response object.- Specified by:
executeRequestin interfaceWellsOfWisdom- Parameters:
request- The HTTP request object.- Returns:
- A built HTTP response object, or null if no response.
-
readFromResponseStream
Reads from the Response object.- Specified by:
readFromResponseStreamin interfaceWellsOfWisdom- Parameters:
response- The response object.- Returns:
- A string generated by gemini-pro and read from the HTTP response object.
-