Class ZhiPuAiChatModel

java.lang.Object
org.springframework.ai.zhipuai.ZhiPuAiChatModel
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 ZhiPuAiChatModel extends Object implements org.springframework.ai.chat.model.ChatModel
ChatModel and StreamingChatModel implementation for ZhiPuAI backed by ZhiPuAiApi.
Since:
1.0.0 M1
Author:
Geng Rong, Alexandros Pappas, Ilayaperumal Gopinathan
See Also:
  • Field Summary

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

    Constructors
    Constructor
    Description
    Creates an instance of the ZhiPuAiChatModel.
    Initializes an instance of the ZhiPuAiChatModel.
    ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
    Initializes an instance of the ZhiPuAiChatModel.
    ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, 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)
    Initializes a new instance of the ZhiPuAiChatModel.
    ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate)
    Initializes an instance of the ZhiPuAiChatModel.
    ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
    Initializes an instance of the ZhiPuAiChatModel.
  • 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
     
    void
    setObservationConvention(org.springframework.ai.chat.observation.ChatModelObservationConvention observationConvention)
     
    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

    clone, 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

    • retryTemplate

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

    • ZhiPuAiChatModel

      public ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi)
      Creates an instance of the ZhiPuAiChatModel.
      Parameters:
      zhiPuAiApi - The ZhiPuAiApi instance to be used for interacting with the ZhiPuAI Chat API.
      Throws:
      IllegalArgumentException - if zhiPuAiApi is null
    • ZhiPuAiChatModel

      public ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options)
      Initializes an instance of the ZhiPuAiChatModel.
      Parameters:
      zhiPuAiApi - The ZhiPuAiApi instance to be used for interacting with the ZhiPuAI Chat API.
      options - The ZhiPuAiChatOptions to configure the chat model.
    • ZhiPuAiChatModel

      public ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate)
      Initializes an instance of the ZhiPuAiChatModel.
      Parameters:
      zhiPuAiApi - The ZhiPuAiApi instance to be used for interacting with the ZhiPuAI Chat API.
      options - The ZhiPuAiChatOptions to configure the chat model.
      retryTemplate - The retry template.
    • ZhiPuAiChatModel

      public ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
      Initializes an instance of the ZhiPuAiChatModel.
      Parameters:
      zhiPuAiApi - The ZhiPuAiApi instance to be used for interacting with the ZhiPuAI Chat API.
      options - The ZhiPuAiChatOptions to configure the chat model.
      retryTemplate - The retry template.
      observationRegistry - The Observation Registry.
    • ZhiPuAiChatModel

      public ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
      Initializes an instance of the ZhiPuAiChatModel.
      Parameters:
      zhiPuAiApi - The ZhiPuAiApi instance to be used for interacting with the ZhiPuAI Chat API.
      toolCallingManager - The tool calling manager
      options - The ZhiPuAiChatOptions to configure the chat model.
      retryTemplate - The retry template.
      observationRegistry - The Observation Registry.
    • ZhiPuAiChatModel

      public ZhiPuAiChatModel(ZhiPuAiApi zhiPuAiApi, ZhiPuAiChatOptions options, 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)
      Initializes a new instance of the ZhiPuAiChatModel.
      Parameters:
      zhiPuAiApi - The ZhiPuAiApi instance to be used for interacting with the ZhiPuAI Chat API.
      options - The ZhiPuAiChatOptions to configure the chat model.
      toolCallingManager - The tool calling manager
      retryTemplate - The retry template.
      observationRegistry - The ObservationRegistry used for instrumentation.
      toolExecutionEligibilityPredicate - The Tool execution eligibility predicate.
  • 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
    • 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>
    • setObservationConvention

      public void setObservationConvention(org.springframework.ai.chat.observation.ChatModelObservationConvention observationConvention)