GeminiChatBuilder

Overview

GeminiChatBuilder is a builder for configuring and creating Gemini chat clients. Allows setting API key, model name, temperature, and memory token limits for the Gemini model.

Methods Summarized

Type
Name
Summary

void

Adds a system message to the chat context.

Sets the Gemini API key.

Builds and returns a ChatClient configured with the specified Gemini model settings.

Creates a new ToolBuilder for defining a custom tool for the AI agent.

Sets the maximum number of memory tokens for chat history.

Sets the Gemini model name.

Sets the temperature for the Gemini model.

void

Injects the built-in Servoy tools (such as user info) into the AI agent.

Methods Detailed

addSystemMessage(message)

Adds a system message to the chat context. This can be a message how the model must behave for this chat session.

Parameters

  • String message The system message to add.

Returns: voidThis builder instance for chaining.

apiKey(key)

Sets the Gemini API key.

Parameters

Returns: GeminiChatBuilder This builder instance.

build()

Builds and returns a ChatClient configured with the specified Gemini model settings.

Returns: ChatClient A configured ChatClient instance.

createTool(toolFunction, name, description)

Creates a new ToolBuilder for defining a custom tool for the AI agent.

Parameters

  • Function toolFunction the function representing the tool's logic

  • String name the name of the tool

  • String description the description of the tool

Returns: ToolBuilder a ToolBuilder instance for further configuration

maxMemoryTokens(tokens)

Sets the maximum number of memory tokens for chat history.

Parameters

  • Number tokens The maximum number of tokens.

Returns: GeminiChatBuilder This builder instance.

modelName(modelName)

Sets the Gemini model name.

Parameters

  • String modelName The model name.

Returns: GeminiChatBuilder This builder instance.

temperature(temperature)

Sets the temperature for the Gemini model.

Parameters

  • Number temperature The temperature value.

Returns: GeminiChatBuilder This builder instance.

useBuiltInTools(useBuiltInTools)

Injects the built-in Servoy tools (such as user info) into the AI agent.

Parameters

  • Boolean useBuiltInTools Boolean to indicate whether to use built-in tools.

Returns: voidThis builder instance for chaining.


Last updated

Was this helpful?