AIAgentLLMWriteSessionAPI

Properties

Link copied to clipboard
abstract val clock: Clock

Clock instance used for adding timestamps on LLM responses and other agent events.

Link copied to clipboard
abstract val config: AIAgentConfig

Config of the agent running the session.

Link copied to clipboard

Represents the current execution environment for the AI agent.

Link copied to clipboard
abstract override var model: LLModel

Represents an override property model of type LLModel. This property is backed by an ActiveProperty, which ensures the property value is dynamically updated based on the active state determined by the isActive parameter.

Link copied to clipboard
abstract override var prompt: Prompt

Represents the prompt object used within the session. The prompt can be accessed or modified only when the session is in an active state, as determined by the isActive predicate.

Link copied to clipboard
abstract override var responseProcessor: ResponseProcessor?

Represents the active response processor within the session. The processor defines the post-processing of messages returned from the LLM.

Link copied to clipboard

A registry that holds information about available tools within the system. This registry is typically used for managing tool instances and their configurations.

Link copied to clipboard
abstract override var tools: List<ToolDescriptor>

Represents a collection of tools that are available for the session. The tools can be accessed or modified only if the session is in an active state.

Functions

Link copied to clipboard
abstract fun appendPrompt(body: PromptBuilder.() -> Unit)

Appends messages to the current prompt by applying modifications defined in the provided block. The modifications are applied using a PromptBuilder instance, allowing for customization of the prompt's content, structure, and associated messages.

Link copied to clipboard
abstract fun changeLLMParams(newParams: LLMParams)

Updates the language model's parameters used in the current session prompt.

Link copied to clipboard
abstract fun changeModel(newModel: LLModel)

Updates the underlying model in the current prompt with the specified new model.

Link copied to clipboard
abstract override fun close()
Link copied to clipboard

Finds a specific tool instance from the tool registry based on the provided tool type.

abstract fun <TArgs, TResult> findTool(toolClass: KClass<out Tool<TArgs, TResult>>): SafeTool<TArgs, TResult>

Finds a tool of the specified class from the tool registry and wraps it in a SafeTool instance.

Link copied to clipboard

Parses a structured response from the language model using the specified configuration.

Link copied to clipboard
abstract suspend fun requestLLM(): Message.Response

Sends a request to the underlying LLM and returns the first response. This method ensures the session is active before executing the request.

Link copied to clipboard
abstract suspend fun requestLLMForceOneTool(tool: Tool<*, *>): Message.Response

Sends a request to the language model while enforcing the use of a specific tool, and returns the response.

Link copied to clipboard
abstract suspend fun requestLLMMultiple(): List<Message.Response>

Sends a request to the language model, potentially utilizing multiple tools, and returns a list of responses from the model.

Link copied to clipboard
abstract suspend fun requestLLMMultipleChoices(): List<LLMChoice>

Sends a request to the language model, potentially receiving multiple choices, and returns a list of choices from the model.

Link copied to clipboard

Sends a request to the language model that enforces the usage of tools and retrieves all responses.

Link copied to clipboard

Sends a request to the language model without utilizing any tools and returns multiple responses.

Link copied to clipboard

Sends a request to the language model that enforces the usage of tools and retrieves the response.

Link copied to clipboard
abstract suspend fun requestLLMStreaming(): Flow<StreamFrame>

Sends a streaming request to the underlying LLM and returns the streamed response. This method ensures the session is active before executing the request.

abstract suspend fun requestLLMStreaming(definition: StructureDefinition? = null): Flow<StreamFrame>

Streams the result of a request to a language model.

Link copied to clipboard
abstract suspend fun <T> requestLLMStructured(config: StructuredRequestConfig<T>, fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>
abstract suspend fun <T> requestLLMStructured(serializer: KSerializer<T>, examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>

Sends a request to LLM and gets a structured response.

Link copied to clipboard

Sends a request to the language model without utilizing any tools and returns the response.

Link copied to clipboard
abstract suspend fun requestModeration(moderatingModel: LLModel? = null): ModerationResult

Sends a moderation request to the specified or default large language model (LLM) for content moderation.

Link copied to clipboard
abstract fun rewritePrompt(body: (prompt: Prompt) -> Prompt)

Rewrites the current prompt by applying a transformation function.

Link copied to clipboard
abstract fun updatePrompt(body: PromptBuilder.() -> Unit)

Updates the current prompt by applying modifications defined in the provided block. The modifications are applied using a PromptBuilder instance, allowing for customization of the prompt's content, structure, and associated messages.