Class GooglePalm2WellsOfWisdomOverVertexAI

java.lang.Object
org.odinware.odinrunes.GooglePalm2WellsOfWisdomOverVertexAI
All Implemented Interfaces:
WellsOfWisdom

public class GooglePalm2WellsOfWisdomOverVertexAI extends Object implements WellsOfWisdom
The GooglePalm2WellsOfWisdomOverVertexAI class is responsible for constructing a valid HTTP request to the Google Palm2 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 Palm2 API.

Once the request is built, it includes the appropriate headers and temporary access token. It returns the constructed request object.

  • Constructor Details

    • GooglePalm2WellsOfWisdomOverVertexAI

      public GooglePalm2WellsOfWisdomOverVertexAI()
  • 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 Palm2 API via GCP's VertexAI using the provided context and messages.
      Specified by:
      buildRequest in interface WellsOfWisdom
      Parameters:
      context - The user context for the conversation.
      odinMessages - The message history for the conversation.
      Returns:
      The constructed request object.
      Throws:
      Exception
    • executeRequest

      public okhttp3.Response executeRequest(okhttp3.Request request)
      Executes a HTTP request and returns the Response object.
      Specified by:
      executeRequest in interface WellsOfWisdom
      Parameters:
      request - The HTTP request object.
      Returns:
      A built HTTP response object, or null if no response.
    • readFromResponseStream

      public String readFromResponseStream(okhttp3.Response response)
      Reads from the Response object.
      Specified by:
      readFromResponseStream in interface WellsOfWisdom
      Parameters:
      response - The response object.
      Returns:
      A string generated by Google Palm2 and read from the HTTP response object.