Class ZCL_LLM_CLIENT_ANTHROPIC
AI Generated documentation.
Overview
The zcl_llm_client_anthropic class is a subclass of zcl_llm_client_base and is designed to interact with the Anthropic LLM (Large Language Model) API. It provides a set of methods to create and manage requests to the Anthropic API, parse responses, and handle errors.
Dependencies
The class depends on the following external objects:
zcl_llm_client_basezcl_llm_http_client_wrapperzcl_llm_commonzif_llm_clientzif_llm_chat_requestzcl_abap_format
Details
Class Structure and Methods
The class has the following public methods:
get_client: Creates a new instance of thezcl_llm_client_anthropicclass and returns a reference to it.constructor: Initializes the class with the provided client and provider configurations.zif_llm_client~new_request: Redefines the method to support Anthropic-specific requirements.build_request_json: Builds the JSON payload for the request, including structured output and tool definitions.parse_message: Parses the message content and handles tool calls.handle_http_response: Handles the HTTP response from the Anthropic API, including error handling and parsing the response structure.
Interaction with Foreign Objects
The class interacts with the following foreign objects:
graph LR
A[Client Configuration] -->|set| B[Provider Configuration]
B -->|set| C[LLM Client Base]
C -->|create| D[zcl_llm_client_anthropic]
D -->|get_client| E[LLM Client]
E -->|new_request| F[Anthropic API]
F -->|build_request_json| G[Request Payload]
G -->|parse_message| H[Message Content]
H -->|handle_http_response| I[HTTP Response]
Logic Flow
The class follows the following logic flow:
get_clientcreates a new instance of the class.constructorinitializes the class with the provided client and provider configurations.zif_llm_client~new_requestis called to create a new request to the Anthropic API.build_request_jsonbuilds the JSON payload for the request.parse_messageparses the message content and handles tool calls.handle_http_responsehandles the HTTP response from the Anthropic API.- The class returns the parsed response to the caller.