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_NAME
Fields inherited from class sk.iway.iwcm.components.ai.providers.SupportLogic
AUDIT_AI_RESPONSE_KEY
Fields inherited from interface sk.iway.iwcm.components.ai.providers.AiInterface
GENERATE_FILE_NAME_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
addUsageAndReturnTotal
(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.HttpRequestBase
getImageResponseRequest
(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request, Prop prop) com.fasterxml.jackson.databind.node.ArrayNode
getImages
(com.fasterxml.jackson.databind.JsonNode jsonNodeRes) org.apache.http.client.methods.HttpRequestBase
getModelsRequest
(javax.servlet.http.HttpServletRequest request) org.apache.http.client.methods.HttpRequestBase
getResponseRequest
(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) getStreamEncoding
(org.apache.http.HttpEntity entity) org.apache.http.client.methods.HttpRequestBase
getStremResponseRequest
(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) com.fasterxml.jackson.databind.JsonNode
handleBufferedReader
(BufferedReader reader, BufferedWriter writer, Map<Integer, String> replacedIncludes) boolean
isInit()
Methods inherited from class sk.iway.iwcm.components.ai.providers.gemini.GeminiSupportService
addPart, addPart, addPartWithFile, getApiKey, getBaseMainObject, getParts, setHeaders
Methods inherited from class sk.iway.iwcm.components.ai.providers.SupportLogic
getAiImageResponse, getAiResponse, getAiStreamResponse, getSupportedModels, handleErrorMessage, handleErrorMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
getProviderId
in interfaceAiInterface
-
getTitleKey
- Specified by:
getTitleKey
in interfaceAiInterface
-
isInit
public boolean isInit()- Specified by:
isInit
in interfaceAiInterface
-
getServiceName
- Specified by:
getServiceName
in interfaceSupportLogicInterface
-
addUsageAndReturnTotal
public int addUsageAndReturnTotal(StringBuilder sb, int addTokens, com.fasterxml.jackson.databind.JsonNode root) - Specified by:
addUsageAndReturnTotal
in interfaceSupportLogicInterface
-
getModelsRequest
public org.apache.http.client.methods.HttpRequestBase getModelsRequest(javax.servlet.http.HttpServletRequest request) - Specified by:
getModelsRequest
in interfaceSupportLogicInterface
-
extractModels
- Specified by:
extractModels
in interfaceSupportLogicInterface
-
getResponseRequest
public org.apache.http.client.methods.HttpRequestBase getResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) - Specified by:
getResponseRequest
in interfaceSupportLogicInterface
-
extractResponseText
- Specified by:
extractResponseText
in interfaceSupportLogicInterface
-
getStremResponseRequest
public org.apache.http.client.methods.HttpRequestBase getStremResponseRequest(String instructions, InputDataDTO inputData, AssistantDefinitionEntity assistant, javax.servlet.http.HttpServletRequest request) - Specified by:
getStremResponseRequest
in interfaceSupportLogicInterface
-
handleBufferedReader
public com.fasterxml.jackson.databind.JsonNode handleBufferedReader(BufferedReader reader, BufferedWriter writer, Map<Integer, String> replacedIncludes) throws IOException- Specified by:
handleBufferedReader
in interfaceSupportLogicInterface
- Throws:
IOException
-
getStreamEncoding
- Specified by:
getStreamEncoding
in 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:
getImageResponseRequest
in interfaceSupportLogicInterface
- Throws:
IOException
-
getFinishError
- Specified by:
getFinishError
in interfaceSupportLogicInterface
-
getImages
public com.fasterxml.jackson.databind.node.ArrayNode getImages(com.fasterxml.jackson.databind.JsonNode jsonNodeRes) - Specified by:
getImages
in interfaceSupportLogicInterface
-
getImageFormat
public String getImageFormat(com.fasterxml.jackson.databind.JsonNode jsonNodeRes, com.fasterxml.jackson.databind.JsonNode jsonImage) - Specified by:
getImageFormat
in interfaceSupportLogicInterface
-
getImageBase64
public String getImageBase64(com.fasterxml.jackson.databind.JsonNode jsonNodeRes, com.fasterxml.jackson.databind.JsonNode jsonImage) - Specified by:
getImageBase64
in interfaceSupportLogicInterface
-
getBonusHtml
- Specified by:
getBonusHtml
in interfaceAiInterface
-
getModelForImageNameGeneration
- Specified by:
getModelForImageNameGeneration
in interfaceSupportLogicInterface
-