Class GeminiService
java.lang.Object
sk.iway.iwcm.components.ai.providers.SupportLogic
sk.iway.iwcm.components.ai.providers.gemini.GeminiSupportService
sk.iway.iwcm.components.ai.providers.gemini.GeminiService
- All Implemented Interfaces:
AiInterface,SupportLogicInterface
Service for Google Gemini AI model integration. We do not use any official SDK, but
rather direct REST calls, so its easy to maintain and we can see what is going on.
docs: https://ai.google.dev/gemini-api/docs
-
Field Summary
Fields inherited from class sk.iway.iwcm.components.ai.providers.gemini.GeminiSupportService
AUTH_KEY, MAPPER, PARTS, SERVICE_NAMEFields inherited from interface sk.iway.iwcm.components.ai.providers.AiInterface
GENERATE_FILE_NAME_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddUsageAndReturnTotal(StringBuilder sb, int addTokens, com.fasterxml.jackson.databind.JsonNode root) extractModels(com.fasterxml.jackson.databind.JsonNode root) extractResponseText(com.fasterxml.jackson.databind.JsonNode jsonNodeRes) getBonusHtml(AssistantDefinitionEntity assistant, Prop prop) getFinishError(com.fasterxml.jackson.databind.JsonNode jsonNodeRes) getImageBase64(com.fasterxml.jackson.databind.JsonNode jsonNodeRes, com.fasterxml.jackson.databind.JsonNode jsonImage) getImageFormat(com.fasterxml.jackson.databind.JsonNode jsonNodeRes, com.fasterxml.jackson.databind.JsonNode jsonImage) org.apache.http.client.methods.HttpRequestBasegetImageResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request, Prop prop) com.fasterxml.jackson.databind.node.ArrayNodegetImages(com.fasterxml.jackson.databind.JsonNode jsonNodeRes) org.apache.http.client.methods.HttpRequestBasegetModelsRequest(javax.servlet.http.HttpServletRequest request) org.apache.http.client.methods.HttpRequestBasegetResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) getStreamEncoding(org.apache.http.HttpEntity entity) org.apache.http.client.methods.HttpRequestBasegetStremResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) handleBufferedReader(BufferedReader reader, BufferedWriter writer, Map<Integer, String> replacedIncludes) booleanisInit()Methods inherited from class sk.iway.iwcm.components.ai.providers.gemini.GeminiSupportService
getApiKey, getBaseMainObject, getBaseMainObjectWithImage, getParts, setHeadersMethods inherited from class sk.iway.iwcm.components.ai.providers.SupportLogic
getAiImageResponse, getAiResponse, getAiStreamResponse, getSupportedModels, handleErrorMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface sk.iway.iwcm.components.ai.providers.AiInterface
getAiImageResponse, getAiResponse, getAiStreamResponse, getRequestBody, getSupportedModels
-
Constructor Details
-
GeminiService
public GeminiService()
-
-
Method Details
-
getProviderId
- Specified by:
getProviderIdin interfaceAiInterface
-
getTitleKey
- Specified by:
getTitleKeyin interfaceAiInterface
-
isInit
public boolean isInit()- Specified by:
isInitin interfaceAiInterface
-
getServiceName
- Specified by:
getServiceNamein interfaceSupportLogicInterface
-
addUsageAndReturnTotal
public int addUsageAndReturnTotal(StringBuilder sb, int addTokens, com.fasterxml.jackson.databind.JsonNode root) - Specified by:
addUsageAndReturnTotalin interfaceSupportLogicInterface
-
getModelsRequest
public org.apache.http.client.methods.HttpRequestBase getModelsRequest(javax.servlet.http.HttpServletRequest request) - Specified by:
getModelsRequestin interfaceSupportLogicInterface
-
extractModels
- Specified by:
extractModelsin interfaceSupportLogicInterface
-
getResponseRequest
public org.apache.http.client.methods.HttpRequestBase getResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) throws IOException - Specified by:
getResponseRequestin interfaceSupportLogicInterface- Throws:
IOException
-
extractResponseText
- Specified by:
extractResponseTextin interfaceSupportLogicInterface
-
getStremResponseRequest
public org.apache.http.client.methods.HttpRequestBase getStremResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) throws IOException - Specified by:
getStremResponseRequestin interfaceSupportLogicInterface- Throws:
IOException
-
handleBufferedReader
public Pair<String,com.fasterxml.jackson.databind.JsonNode> handleBufferedReader(BufferedReader reader, BufferedWriter writer, Map<Integer, String> replacedIncludes) throws IOException- Specified by:
handleBufferedReaderin interfaceSupportLogicInterface- Throws:
IOException
-
getStreamEncoding
- Specified by:
getStreamEncodingin interfaceSupportLogicInterface
-
getImageResponseRequest
public org.apache.http.client.methods.HttpRequestBase getImageResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request, Prop prop) throws IOException - Specified by:
getImageResponseRequestin interfaceSupportLogicInterface- Throws:
IOException
-
getFinishError
- Specified by:
getFinishErrorin interfaceSupportLogicInterface
-
getImages
public com.fasterxml.jackson.databind.node.ArrayNode getImages(com.fasterxml.jackson.databind.JsonNode jsonNodeRes) - Specified by:
getImagesin interfaceSupportLogicInterface
-
getImageFormat
public String getImageFormat(com.fasterxml.jackson.databind.JsonNode jsonNodeRes, com.fasterxml.jackson.databind.JsonNode jsonImage) - Specified by:
getImageFormatin interfaceSupportLogicInterface
-
getImageBase64
public String getImageBase64(com.fasterxml.jackson.databind.JsonNode jsonNodeRes, com.fasterxml.jackson.databind.JsonNode jsonImage) - Specified by:
getImageBase64in interfaceSupportLogicInterface
-
getBonusHtml
- Specified by:
getBonusHtmlin interfaceAiInterface
-
getModelForImageNameGeneration
- Specified by:
getModelForImageNameGenerationin interfaceSupportLogicInterface
-