Class DashScopeChatModel

java.lang.Object
com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel
All Implemented Interfaces:
org.springframework.ai.chat.model.ChatModel, org.springframework.ai.chat.model.StreamingChatModel, org.springframework.ai.model.Model<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>, org.springframework.ai.model.StreamingModel<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>

public class DashScopeChatModel extends Object implements org.springframework.ai.chat.model.ChatModel
ChatModel implementation for Alibaba DashScope backed by Generation.
Author:
yuluo, yuluo
See Also:
  • ChatModel
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    final org.springframework.retry.support.RetryTemplate
    The retry template used to retry the OpenAI API calls.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DashScopeChatModel(DashScopeApi dashscopeApi, DashScopeChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
     
    DashScopeChatModel(DashScopeApi dashscopeApi, DashScopeChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry, org.springframework.ai.model.tool.ToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    org.springframework.ai.chat.model.ChatResponse
    call(org.springframework.ai.chat.prompt.Prompt prompt)
     
     
     
    org.springframework.ai.chat.prompt.ChatOptions
     
    org.springframework.ai.chat.model.ChatResponse
    internalCall(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
     
    reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse>
    internalStream(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
     
    Returns a builder pre-populated with the current configuration for mutation.
    void
     
    void
    setObservationConvention(org.springframework.ai.chat.observation.ChatModelObservationConvention observationConvention)
    Use the provided convention for reporting observation data
    reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse>
    stream(org.springframework.ai.chat.prompt.Prompt prompt)
     

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.ai.chat.model.ChatModel

    call, call

    Methods inherited from interface org.springframework.ai.chat.model.StreamingChatModel

    stream, stream
  • Field Details

    • DEFAULT_MODEL_NAME

      public static final String DEFAULT_MODEL_NAME
    • retryTemplate

      public final org.springframework.retry.support.RetryTemplate retryTemplate
      The retry template used to retry the OpenAI API calls.
  • Constructor Details

    • DashScopeChatModel

      public DashScopeChatModel(DashScopeApi dashscopeApi, DashScopeChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
    • DashScopeChatModel

      public DashScopeChatModel(DashScopeApi dashscopeApi, DashScopeChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry, org.springframework.ai.model.tool.ToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate)
  • Method Details

    • call

      public org.springframework.ai.chat.model.ChatResponse call(org.springframework.ai.chat.prompt.Prompt prompt)
      Specified by:
      call in interface org.springframework.ai.chat.model.ChatModel
      Specified by:
      call in interface org.springframework.ai.model.Model<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>
    • getDefaultOptions

      public org.springframework.ai.chat.prompt.ChatOptions getDefaultOptions()
      Specified by:
      getDefaultOptions in interface org.springframework.ai.chat.model.ChatModel
    • internalCall

      public org.springframework.ai.chat.model.ChatResponse internalCall(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
    • stream

      public reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> stream(org.springframework.ai.chat.prompt.Prompt prompt)
      Specified by:
      stream in interface org.springframework.ai.chat.model.ChatModel
      Specified by:
      stream in interface org.springframework.ai.chat.model.StreamingChatModel
      Specified by:
      stream in interface org.springframework.ai.model.StreamingModel<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>
    • internalStream

      public reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> internalStream(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
    • getDashScopeChatOptions

      public DashScopeChatOptions getDashScopeChatOptions()
    • setDashScopeChatOptions

      public void setDashScopeChatOptions(DashScopeChatOptions options)
    • setObservationConvention

      public void setObservationConvention(org.springframework.ai.chat.observation.ChatModelObservationConvention observationConvention)
      Use the provided convention for reporting observation data
      Parameters:
      observationConvention - The provided convention
    • mutate

      public DashScopeChatModel.Builder mutate()
      Returns a builder pre-populated with the current configuration for mutation.
    • clone

      public DashScopeChatModel clone()
      Overrides:
      clone in class Object
    • builder

      public static DashScopeChatModel.Builder builder()