Class DashScopeApi
java.lang.Object
com.alibaba.cloud.ai.dashscope.api.DashScopeApi
- Since:
- 1.0.0-M2
- Author:
- nuocheng.lxm, yuluo, YunKui Lu
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDashScopeApi(String baseUrl, org.springframework.ai.model.ApiKey apiKey, org.springframework.util.MultiValueMap<String, String> header, String completionsPath, String embeddingsPath, String workSpaceId, 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 TypeMethodDescriptionstatic DashScopeApi.Builderbuilder()org.springframework.http.ResponseEntity<DashScopeApiSpec.ChatCompletion>Creates a model response for the given chat conversation.org.springframework.http.ResponseEntity<DashScopeApiSpec.ChatCompletion>chatCompletionEntity(DashScopeApiSpec.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a model response for the given chat conversation.reactor.core.publisher.Flux<DashScopeApiSpec.ChatCompletionChunk>Creates a streaming chat response for the given chat conversation.reactor.core.publisher.Flux<DashScopeApiSpec.ChatCompletionChunk>chatCompletionStream(DashScopeApiSpec.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a streaming chat response for the given chat conversation.booleandeletePipelineDocument(String pipelineId, List<String> idList) org.springframework.http.ResponseEntity<DashScopeApiSpec.DocumentSplitResponse>documentSplit(org.springframework.ai.document.Document document, DashScopeDocumentTransformerOptions options) org.springframework.http.ResponseEntity<DashScopeApiSpec.EmbeddingList>embeddings(DashScopeApiSpec.EmbeddingRequest embeddingRequest) EmbeddinggetFileParseResult(String categoryId, DashScopeApiSpec.UploadRequest.QueryFileRequest request) getPipelineIdByName(String pipelineName) static Stringmutate()Returns a builder pre-populated with the current configuration for mutation.org.springframework.http.ResponseEntity<DashScopeApiSpec.CommonResponse<DashScopeApiSpec.QueryFileResponseData>>queryFileInfo(String categoryId, DashScopeApiSpec.UploadRequest.QueryFileRequest request) org.springframework.http.ResponseEntity<DashScopeApiSpec.RerankResponse>rerankEntity(DashScopeApiSpec.RerankRequest rerankRequest) Creates rerank request for dashscope rerank model.List<org.springframework.ai.document.Document>retriever(String pipelineId, String query, DashScopeDocumentRetrieverOptions searchOption) upload(File file, DashScopeApiSpec.UploadRequest request) voidupsertPipeline(List<org.springframework.ai.document.Document> documents, DashScopeStoreOptions storeOptions)
-
Field Details
-
DEFAULT_CHAT_MODEL
Default chat model -
DEFAULT_EMBEDDING_MODEL
-
DEFAULT_EMBEDDING_TEXT_TYPE
-
-
Constructor Details
-
DashScopeApi
public DashScopeApi(String baseUrl, org.springframework.ai.model.ApiKey apiKey, org.springframework.util.MultiValueMap<String, String> header, String completionsPath, String embeddingsPath, String workSpaceId, 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- OpenAI apiKey.header- the http headers to use.completionsPath- the path to the chat completions endpoint.embeddingsPath- the path to the embeddings endpoint.workSpaceId- the workspace ID to use.restClientBuilder- RestClient builder.webClientBuilder- WebClient builder.responseErrorHandler- Response error handler.
-
-
Method Details
-
mutate
Returns a builder pre-populated with the current configuration for mutation. -
builder
-
embeddings
public org.springframework.http.ResponseEntity<DashScopeApiSpec.EmbeddingList> embeddings(DashScopeApiSpec.EmbeddingRequest embeddingRequest) Embedding -
upload
-
queryFileInfo
public org.springframework.http.ResponseEntity<DashScopeApiSpec.CommonResponse<DashScopeApiSpec.QueryFileResponseData>> queryFileInfo(String categoryId, DashScopeApiSpec.UploadRequest.QueryFileRequest request) -
getFileParseResult
public String getFileParseResult(String categoryId, DashScopeApiSpec.UploadRequest.QueryFileRequest request) -
documentSplit
public org.springframework.http.ResponseEntity<DashScopeApiSpec.DocumentSplitResponse> documentSplit(org.springframework.ai.document.Document document, DashScopeDocumentTransformerOptions options) -
getPipelineIdByName
-
upsertPipeline
public void upsertPipeline(List<org.springframework.ai.document.Document> documents, DashScopeStoreOptions storeOptions) -
deletePipelineDocument
-
retriever
public List<org.springframework.ai.document.Document> retriever(String pipelineId, String query, DashScopeDocumentRetrieverOptions searchOption) -
getTextContent
public static String getTextContent(List<DashScopeApiSpec.ChatCompletionMessage.MediaContent> content) -
chatCompletionEntity
public org.springframework.http.ResponseEntity<DashScopeApiSpec.ChatCompletion> chatCompletionEntity(DashScopeApiSpec.ChatCompletionRequest chatRequest) Creates a model response for the given chat conversation.- Parameters:
chatRequest- The chat completion request.- Returns:
- Entity response with
DashScopeApiSpec.ChatCompletionas a body and HTTP status code and headers.
-
chatCompletionEntity
public org.springframework.http.ResponseEntity<DashScopeApiSpec.ChatCompletion> chatCompletionEntity(DashScopeApiSpec.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a model response for the given chat conversation.- Parameters:
chatRequest- The chat completion request.additionalHttpHeader- Optional, additional HTTP headers to be added to the request.- Returns:
- Entity response with
DashScopeApiSpec.ChatCompletionas a body and HTTP status code and headers.
-
chatCompletionStream
public reactor.core.publisher.Flux<DashScopeApiSpec.ChatCompletionChunk> chatCompletionStream(DashScopeApiSpec.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.
-
chatCompletionStream
public reactor.core.publisher.Flux<DashScopeApiSpec.ChatCompletionChunk> chatCompletionStream(DashScopeApiSpec.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a streaming chat response for the given chat conversation.- Parameters:
chatRequest- The chat completion request. Must have the stream property set to true.additionalHttpHeader- Optional, additional HTTP headers to be added to the request.- Returns:
- Returns a
Fluxstream from chat completion chunks.
-
rerankEntity
public org.springframework.http.ResponseEntity<DashScopeApiSpec.RerankResponse> rerankEntity(DashScopeApiSpec.RerankRequest rerankRequest) Creates rerank request for dashscope rerank model.- Parameters:
rerankRequest- The chat completion request.- Returns:
- Entity response with
DashScopeApiSpec.ChatCompletionas a body and HTTP status code and headers.
-