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
FieldsModifier and TypeFieldDescriptionfinal org.springframework.retry.support.RetryTemplateThe retry template used to retry the QianFan API calls. -
Constructor Summary
ConstructorsConstructorDescriptionQianFanChatModel(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.voidsetObservationConvention(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, waitMethods 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:ModelExecutes a method call to the AI model. -
stream
Description copied from interface:StreamingModelExecutes a method call to the AI model.- Specified by:
streamin interfaceChatModel- Specified by:
streamin interfaceStreamingChatModel- Specified by:
streamin 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:
getDefaultOptionsin interfaceChatModel
-
setObservationConvention
-