Class QianFanApi
java.lang.Object
org.springframework.ai.qianfan.api.auth.AuthApi
org.springframework.ai.qianfan.api.QianFanApi
Single class implementation of the QianFan Chat Completion API and Embedding API.
QianFan Docs
- Since:
- 1.0
- Author:
- Geng Rong, Thomas Vitale
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents a chat completion response returned by model, based on the provided input.static final recordRepresents a streamed chunk of a chat completion response returned by model, based on the provided input.static final recordMessage comprising the conversation.static final recordCreates a model response for the given chat conversation.static enumQianFan Chat Completion Models: QianFan Model.static final recordRepresents an embedding vector returned by embedding endpoint.static final recordList of multiple embedding responses.static enumQianFan Embeddings Models: Embeddings.static final recordCreates an embedding vector representing the input text.static final recordUsage statistics for the completion request. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionQianFanApi(String apiKey, String secretKey) Create a new chat completion api with default base URL.QianFanApi(String baseUrl, String apiKey, String secretKey) Create a new chat completion api.QianFanApi(String baseUrl, String apiKey, String secretKey, org.springframework.web.client.RestClient.Builder restClientBuilder) Create a new chat completion api.QianFanApi(String baseUrl, String apiKey, String secretKey, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new chat completion api.QianFanApi(String baseUrl, String apiKey, String secretKey, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new chat completion api. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<QianFanApi.ChatCompletion>chatCompletionEntity(QianFanApi.ChatCompletionRequest chatRequest) Creates a model response for the given chat conversation.reactor.core.publisher.Flux<QianFanApi.ChatCompletionChunk>chatCompletionStream(QianFanApi.ChatCompletionRequest chatRequest) Creates a streaming chat response for the given chat conversation.org.springframework.http.ResponseEntity<QianFanApi.EmbeddingList>embeddings(QianFanApi.EmbeddingRequest embeddingRequest) Creates an embedding vector representing the input text or token array.Methods inherited from class org.springframework.ai.qianfan.api.auth.AuthApi
getAccessToken
-
Field Details
-
DEFAULT_CHAT_MODEL
-
DEFAULT_EMBEDDING_MODEL
-
-
Constructor Details
-
QianFanApi
Create a new chat completion api with default base URL.- Parameters:
apiKey- QianFan api key.secretKey- QianFan secret key.
-
QianFanApi
Create a new chat completion api.- Parameters:
baseUrl- api base URL.apiKey- QianFan api key.secretKey- QianFan secret key.
-
QianFanApi
public QianFanApi(String baseUrl, String apiKey, String secretKey, org.springframework.web.client.RestClient.Builder restClientBuilder) Create a new chat completion api.- Parameters:
baseUrl- api base URL.apiKey- QianFan api key.secretKey- QianFan secret key.restClientBuilder- RestClient builder.
-
QianFanApi
public QianFanApi(String baseUrl, String apiKey, String secretKey, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new chat completion api.- Parameters:
baseUrl- api base URL.apiKey- QianFan api key.secretKey- QianFan secret key.restClientBuilder- RestClient builder.responseErrorHandler- Response error handler.
-
QianFanApi
public QianFanApi(String baseUrl, String apiKey, String secretKey, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new chat completion api.- Parameters:
baseUrl- api base URL.apiKey- QianFan api key.secretKey- QianFan secret key.restClientBuilder- RestClient builder.webClientBuilder- WebClient builder.responseErrorHandler- Response error handler.
-
-
Method Details
-
chatCompletionEntity
public org.springframework.http.ResponseEntity<QianFanApi.ChatCompletion> chatCompletionEntity(QianFanApi.ChatCompletionRequest chatRequest) Creates a model response for the given chat conversation.- Parameters:
chatRequest- The chat completion request.- Returns:
- Entity response with
QianFanApi.ChatCompletionas a body and HTTP status code and headers.
-
chatCompletionStream
public reactor.core.publisher.Flux<QianFanApi.ChatCompletionChunk> chatCompletionStream(QianFanApi.ChatCompletionRequest chatRequest) Creates a streaming chat response for the given chat conversation.- Parameters:
chatRequest- The chat completion request. Must have the stream property set to true.- Returns:
- Returns a
Fluxstream from chat completion chunks.
-
embeddings
public org.springframework.http.ResponseEntity<QianFanApi.EmbeddingList> embeddings(QianFanApi.EmbeddingRequest embeddingRequest) Creates an embedding vector representing the input text or token array.- Parameters:
embeddingRequest- The embedding request.- Returns:
- Returns list of
QianFanApi.Embeddingwrapped inQianFanApi.EmbeddingList.
-