Package com.t4a.api

Class JavaActionExecutor

java.lang.Object
com.t4a.api.JavaActionExecutor
All Implemented Interfaces:
AIActionExecutor
Direct Known Subclasses:
JavaClassExecutor, JavaMethodExecutor

public abstract class JavaActionExecutor extends Object implements AIActionExecutor
This is the base class for all the java based executors with common functionality
  • Constructor Details

    • JavaActionExecutor

      public JavaActionExecutor()
  • Method Details

    • mapType

      public com.google.cloud.vertexai.api.Type mapType(Class<?> type)
      Map Java type to Gemini type
      Parameters:
      type -
      Returns:
    • mapTypeForPojo

      public com.google.cloud.vertexai.api.Type mapTypeForPojo(Class<?> type)
    • mapType

      public com.google.cloud.vertexai.api.Type mapType(String type)
      Map String to Gemini type
      Parameters:
      type -
      Returns:
    • mapClassToFun

      public com.google.cloud.vertexai.api.Schema mapClassToFun(String className, String funName, String discription) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • getBuildForJson

      protected com.google.cloud.vertexai.api.Schema getBuildForJson(Map<String,Object> mapOfMapsForJason)
      Create Gemini Schema object this will be used to create funciton
      Returns:
    • getBuild

      protected com.google.cloud.vertexai.api.Schema getBuild(Map<String,Object> properties)
    • getBuild

      protected com.google.cloud.vertexai.api.Schema getBuild(com.google.cloud.vertexai.api.Type type, String property)
      Create schema from single property
      Parameters:
      type -
      property -
      Returns:
    • getBuildFunction

      protected com.google.cloud.vertexai.api.FunctionDeclaration getBuildFunction(String funName, String discription)
      Create function from the funciton name and discription , this is the main method behind all the magic it builds based on the properties which are initially created using properties, this properties are created by the subclasses by mapping the method or java class. Any subclass has to populate the properties map object
      Parameters:
      funName -
      discription -
      Returns:
    • getBuildFunction

      protected com.google.cloud.vertexai.api.FunctionDeclaration getBuildFunction(Map<String,Object> mapOfMapsForJason, String funName, String discription)
    • protobufToMap

      public Map<String,Object> protobufToMap(Map<String,com.google.protobuf.Value> protobufMap)
    • getPropertyValuesMapMap

      public Map<String,Object> getPropertyValuesMapMap(com.google.cloud.vertexai.api.GenerateContentResponse response)
    • getPropertyValuesMap

      public Map<String,Object> getPropertyValuesMap(String responseFromAI)
    • getPropertyValuesMap

      public Map<String,Object> getPropertyValuesMap(com.google.cloud.vertexai.api.GenerateContentResponse response)
      Fetches the values populated by gemini into the function , this will get mapped to a MAP which can then converted to json or invoke method or make http call
      Parameters:
      response -
      Returns:
    • getPropertyValuesJsonString

      public String getPropertyValuesJsonString(com.google.cloud.vertexai.api.GenerateContentResponse response)
    • getPropertyValuesJsonString

      public String getPropertyValuesJsonString(com.google.cloud.vertexai.api.GenerateContentResponse response, boolean asIs)
    • getProperties

      protected abstract Map<String,Object> getProperties()
    • getGson

      protected abstract com.google.gson.Gson getGson()