Package org.springframework.ai.qianfan
Class QianFanChatModel
java.lang.Object
org.springframework.ai.qianfan.QianFanChatModel
- All Implemented Interfaces:
ChatModel
,StreamingChatModel
,Model<Prompt,
,ChatResponse> StreamingModel<Prompt,
ChatResponse>
- Since:
- 1.0
- Author:
- Geng Rong
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal org.springframework.retry.support.RetryTemplate
The retry template used to retry the QianFan API calls. -
Constructor Summary
ConstructorDescriptionQianFanChatModel
(QianFanApi qianFanApi) Creates an instance of the QianFanChatModel.QianFanChatModel
(QianFanApi qianFanApi, QianFanChatOptions options) Initializes an instance of the QianFanChatModel.QianFanChatModel
(QianFanApi qianFanApi, QianFanChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate) Initializes a new instance of the QianFanChatModel.QianFanChatModel
(QianFanApi qianFanApi, QianFanChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Initializes a new instance of the QianFanChatModel. -
Method Summary
Modifier and TypeMethodDescriptionExecutes a method call to the AI model.createRequest
(Prompt prompt, boolean stream) Accessible for testing.void
setObservationConvention
(ChatModelObservationConvention observationConvention) reactor.core.publisher.Flux<ChatResponse>
Executes a method call to the AI model.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.StreamingChatModel
stream, stream
-
Field Details
-
retryTemplate
public final org.springframework.retry.support.RetryTemplate retryTemplateThe retry template used to retry the QianFan API calls.
-
-
Constructor Details
-
QianFanChatModel
Creates an instance of the QianFanChatModel.- Parameters:
qianFanApi
- The QianFanApi instance to be used for interacting with the QianFan Chat API.- Throws:
IllegalArgumentException
- if QianFanApi is null
-
QianFanChatModel
Initializes an instance of the QianFanChatModel.- Parameters:
qianFanApi
- The QianFanApi instance to be used for interacting with the QianFan Chat API.options
- The QianFanChatOptions to configure the chat client.
-
QianFanChatModel
public QianFanChatModel(QianFanApi qianFanApi, QianFanChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate) Initializes a new instance of the QianFanChatModel.- Parameters:
qianFanApi
- The QianFanApi instance to be used for interacting with the QianFan Chat API.options
- The QianFanChatOptions to configure the chat client.retryTemplate
- The retry template.
-
QianFanChatModel
public QianFanChatModel(QianFanApi qianFanApi, QianFanChatOptions options, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Initializes a new instance of the QianFanChatModel.- Parameters:
qianFanApi
- The QianFanApi instance to be used for interacting with the QianFan Chat API.options
- The QianFanChatOptions to configure the chat client.retryTemplate
- The retry template.observationRegistry
- The ObservationRegistry used for instrumentation.
-
-
Method Details
-
call
Description copied from interface:Model
Executes a method call to the AI model. -
stream
Description copied from interface:StreamingModel
Executes a method call to the AI model.- Specified by:
stream
in interfaceChatModel
- Specified by:
stream
in interfaceStreamingChatModel
- Specified by:
stream
in interfaceStreamingModel<Prompt,
ChatResponse> - Parameters:
prompt
- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
createRequest
Accessible for testing. -
getDefaultOptions
- Specified by:
getDefaultOptions
in interfaceChatModel
-
setObservationConvention
-