Class GeminiAdapter
java.lang.Object
uno.anahata.ai.gemini.GeminiAdapter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.genai.types.SchemagetGeminiSchema(Class<?> clazz) Generates a GeminiSchemafor a given Java class.static com.google.genai.types.SchemagetGeminiSchema(Type type) Generates a GeminiSchemafor a given Java type.static com.google.genai.types.SchemagetGeminiSchema(Type type, boolean includeJsonSchemaId) Generates a GeminiSchemafor a given Java type, with an option to include a JSON schema ID.getToolCallId(com.google.genai.types.Part part) Extracts the tool call ID from a Part, checking both FunctionCall and FunctionResponse.static com.google.genai.types.ContentprepareForApi(com.google.genai.types.Content content) Prepares a Content object for the Gemini API by ensuring all FunctionCall arguments and FunctionResponse results are converted to pure JSON primitives (Maps, Lists, Primitives).
-
Constructor Details
-
GeminiAdapter
public GeminiAdapter()
-
-
Method Details
-
getGeminiSchema
-
getGeminiSchema
public static com.google.genai.types.Schema getGeminiSchema(Type type, boolean includeJsonSchemaId) throws Exception Generates a GeminiSchemafor a given Java type, with an option to include a JSON schema ID.- Parameters:
type- The Java type to convert.includeJsonSchemaId- Whether to include a unique ID in the schema.- Returns:
- The corresponding Gemini Schema.
- Throws:
Exception- if schema generation fails.
-
getGeminiSchema
-
getToolCallId
-
prepareForApi
public static com.google.genai.types.Content prepareForApi(com.google.genai.types.Content content) Prepares a Content object for the Gemini API by ensuring all FunctionCall arguments and FunctionResponse results are converted to pure JSON primitives (Maps, Lists, Primitives). This prevents "greedy" serialization crashes in external mappers.- Parameters:
content- The content to prepare.- Returns:
- A new Content object with purified parts, or the original if no changes were needed.
-
