AIAgentLLMReadSession

Represents a session for interacting with a language model (LLM) in a read-only context within an AI agent setup. This session is configured with a set of tools, an executor for handling prompt execution, a prompt definition, a language model, and specific session configurations.

Parameters

tools

A list of tool descriptors that define the tools available for this session.

executor

The PromptExecutor responsible for handling execution of prompts within this session.

prompt

The Prompt object specifying the input messages and parameters for the session.

model

The language model instance to be used for processing prompts in this session.

config

The configuration settings for the AI agent session.

Properties

Link copied to clipboard
open val model: LLModel

Represents the active language model used within the session.

Link copied to clipboard
open val prompt: Prompt

Represents the current prompt associated with the LLM session. The prompt captures the input messages, model configuration, and parameters used for interactions with the underlying language model.

Link copied to clipboard

Provides a list of tools based on the current active state.

Functions

Link copied to clipboard
override fun close()
Link copied to clipboard
open 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
Link copied to clipboard

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

Link copied to clipboard
Link copied to clipboard
open suspend fun <T> requestLLMStructured(structure: StructuredData<T>, retries: Int = 1, fixingModel: LLModel = OpenAIModels.Chat.GPT4o): Result<StructuredResponse<T>>

Coerce LLM to provide a structured output.

Link copied to clipboard

Expect LLM to reply in a structured format and try to parse it. For more robust version with model coercion and correction see requestLLMStructured

Link copied to clipboard