Class ZCL_LLM_CHAT_REQUEST
AI Generated documentation.
Overview
The zcl_llm_chat_request
class implements the zif_llm_chat_request
interface and manages chat requests for a language learning model (LLM) system. It provides functionality to:
- Manage messages (add, clear, retrieve)
- Handle tools and tool results
- Configure structured output settings
- Manage tool choices
Key public methods:
add_message/add_messages
: Add single or multiple messages to the requestadd_tool/add_tools
: Add single or multiple tools with optional tool choice settingsadd_tool_result
: Convert tool results to messagesset_structured_output
: Configure structured output schema and settingsget_internal_request
: Retrieve the internal request stateclear_messages/clear_tools
: Reset message or tool collections
Dependencies
zif_llm_chat_request
: Interface implemented by this classzif_llm_client
: Interface providing role definitionszcl_llm_common
: Utility class for JSON conversionzllm_request
: Structure type for internal request statezllm_msg
: Structure type for messages
Details
The class follows a stateful design pattern where the internal request state is maintained throughout the object's lifecycle. The interaction flow can be visualized as follows:
graph TD
A[Client] -->|Constructor| B[Initialize Request]
B --> C[Message Management]
B --> D[Tool Management]
B --> E[Structured Output]
C -->|add_message/add_messages| F[Message Collection]
C -->|clear_messages| F
D -->|add_tool/add_tools| G[Tool Collection]
D -->|add_tool_result| F
D -->|clear_tools| G
E -->|set_structured_output| H[Output Configuration]
E -->|set_structured_output_active| H
F --> I[Internal Request State]
G --> I
H --> I
The class maintains separation of concerns between:
- Message handling (chat history, tool results)
- Tool management (available tools, tool choices)
- Structured output configuration
All operations modify the internal request
instance variable, which can be accessed via get_internal_request
. The class acts as a facade, providing a simplified interface for managing complex chat request configurations.