Class AbstractBedrockChatModel<T extends BedrockChatModelResponse>

java.lang.Object
dev.langchain4j.model.bedrock.internal.AbstractSharedBedrockChatModel
dev.langchain4j.model.bedrock.internal.AbstractBedrockChatModel<T>
All Implemented Interfaces:
ChatLanguageModel
Direct Known Subclasses:
BedrockAI21LabsChatModel, BedrockAnthropicCompletionChatModel, BedrockAnthropicMessageChatModel, BedrockCohereChatModel, BedrockLlamaChatModel, BedrockMistralAiChatModel, BedrockStabilityAIChatModel, BedrockTitanChatModel

public abstract class AbstractBedrockChatModel<T extends BedrockChatModelResponse> extends AbstractSharedBedrockChatModel implements ChatLanguageModel
Bedrock chat model
  • Constructor Details

    • AbstractBedrockChatModel

      public AbstractBedrockChatModel()
  • Method Details

    • generate

      public Response<AiMessage> generate(List<ChatMessage> messages)
      Description copied from interface: ChatLanguageModel
      Generates a response from the model based on a sequence of messages. Typically, the sequence contains messages in the following order: System (optional) - User - AI - User - AI - User ...
      Specified by:
      generate in interface ChatLanguageModel
      Parameters:
      messages - A list of messages.
      Returns:
      The response generated by the model.
    • toAiMessage

      public Response<AiMessage> toAiMessage(T result)
    • getRequestParameters

      protected abstract Map<String,Object> getRequestParameters(String prompt)
      Get request parameters
      Overrides:
      getRequestParameters in class AbstractSharedBedrockChatModel
      Parameters:
      prompt - prompt
      Returns:
      request body
    • getResponseClassType

      protected abstract Class<T> getResponseClassType()
      Get response class type
      Returns:
      response class type
    • invoke

      protected software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse invoke(software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest invokeModelRequest, ChatModelRequestContext requestContext)
      Invoke call to the API
      Parameters:
      invokeModelRequest - invokeModelRequest
      requestContext - requestContext
      Returns:
      invoke model response
    • of

      protected static Map<String,Object> of(String key, Object value)
      Create map with single entry
      Parameters:
      key - key
      value - value
      Returns:
      map