Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: yuluo-yx <[email protected]>
  • Loading branch information
yuluo-yx committed Sep 24, 2024
1 parent 4147474 commit e25b59c
Showing 1 changed file with 23 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,13 @@
* @since 2024/8/16 11:45
*/
@ConditionalOnClass(DashScopeApi.class)
@AutoConfiguration(after = {
RestClientAutoConfiguration.class,
WebClientAutoConfiguration.class,
SpringAiRetryAutoConfiguration.class
})
@EnableConfigurationProperties({
DashScopeConnectionProperties.class,
DashScopeChatProperties.class,
DashScopeImageProperties.class,
DashScopeAudioTranscriptionProperties.class,
DashScopeAudioSpeechProperties.class,
DashScopeEmbeddingProperties.class })
@ImportAutoConfiguration(classes = {
SpringAiRetryAutoConfiguration.class,
RestClientAutoConfiguration.class,
WebClientAutoConfiguration.class
})
@AutoConfiguration(after = { RestClientAutoConfiguration.class, WebClientAutoConfiguration.class,
SpringAiRetryAutoConfiguration.class })
@EnableConfigurationProperties({ DashScopeConnectionProperties.class, DashScopeChatProperties.class,
DashScopeImageProperties.class, DashScopeAudioTranscriptionProperties.class,
DashScopeAudioSpeechProperties.class, DashScopeEmbeddingProperties.class })
@ImportAutoConfiguration(classes = { SpringAiRetryAutoConfiguration.class, RestClientAutoConfiguration.class,
WebClientAutoConfiguration.class })
public class DashScopeAutoConfiguration {

@Bean
Expand All @@ -99,12 +89,8 @@ public Transcription transcription() {

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(
prefix = DashScopeChatProperties.CONFIG_PREFIX,
name = "enabled",
havingValue = "true",
matchIfMissing = true
)
@ConditionalOnProperty(prefix = DashScopeChatProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
matchIfMissing = true)
public DashScopeChatModel dashscopeChatModel(DashScopeConnectionProperties commonProperties,
DashScopeChatProperties chatProperties, RestClient.Builder restClientBuilder,
WebClient.Builder webClientBuilder, List<FunctionCallback> toolFunctionCallbacks,
Expand All @@ -124,12 +110,8 @@ public DashScopeChatModel dashscopeChatModel(DashScopeConnectionProperties commo

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(
prefix = DashScopeEmbeddingProperties.CONFIG_PREFIX,
name = "enabled",
havingValue = "true",
matchIfMissing = true
)
@ConditionalOnProperty(prefix = DashScopeEmbeddingProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
matchIfMissing = true)
public DashScopeApi dashscopeChatApi(DashScopeConnectionProperties commonProperties,
DashScopeChatProperties chatProperties, RestClient.Builder restClientBuilder,
WebClient.Builder webClientBuilder, ResponseErrorHandler responseErrorHandler) {
Expand All @@ -143,12 +125,8 @@ public DashScopeApi dashscopeChatApi(DashScopeConnectionProperties commonPropert

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(
prefix = DashScopeEmbeddingProperties.CONFIG_PREFIX,
name = "enabled",
havingValue = "true",
matchIfMissing = true
)
@ConditionalOnProperty(prefix = DashScopeEmbeddingProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
matchIfMissing = true)
public DashScopeEmbeddingModel dashscopeEmbeddingModel(DashScopeConnectionProperties commonProperties,
DashScopeEmbeddingProperties embeddingProperties, RestClient.Builder restClientBuilder,
WebClient.Builder webClientBuilder, RetryTemplate retryTemplate,
Expand All @@ -161,13 +139,9 @@ public DashScopeEmbeddingModel dashscopeEmbeddingModel(DashScopeConnectionProper
embeddingProperties.getOptions(), retryTemplate);
}

public DashScopeApi dashscopeEmbeddingApi(
DashScopeConnectionProperties commonProperties,
DashScopeEmbeddingProperties embeddingProperties,
RestClient.Builder restClientBuilder,
WebClient.Builder webClientBuilder,
ResponseErrorHandler responseErrorHandler
) {
public DashScopeApi dashscopeEmbeddingApi(DashScopeConnectionProperties commonProperties,
DashScopeEmbeddingProperties embeddingProperties, RestClient.Builder restClientBuilder,
WebClient.Builder webClientBuilder, ResponseErrorHandler responseErrorHandler) {
DashScopeAutoConfiguration.ResolvedConnectionProperties resolved = resolveConnectionProperties(commonProperties,
embeddingProperties, "embedding");

Expand All @@ -177,12 +151,8 @@ public DashScopeApi dashscopeEmbeddingApi(

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(
prefix = DashScopeEmbeddingProperties.CONFIG_PREFIX,
name = "enabled",
havingValue = "true",
matchIfMissing = true
)
@ConditionalOnProperty(prefix = DashScopeEmbeddingProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
matchIfMissing = true)
public DashScopeAgentApi dashscopeAgentApi(DashScopeConnectionProperties commonProperties,
DashScopeChatProperties chatProperties, RestClient.Builder restClientBuilder,
WebClient.Builder webClientBuilder, ResponseErrorHandler responseErrorHandler) {
Expand All @@ -203,12 +173,8 @@ public RestClientCustomizer restClientCustomizer(DashScopeConnectionProperties c

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(
prefix = DashScopeImageProperties.CONFIG_PREFIX,
name = "enabled",
havingValue = "true",
matchIfMissing = true
)
@ConditionalOnProperty(prefix = DashScopeImageProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
matchIfMissing = true)
public DashScopeImageModel dashScopeImageModel(DashScopeConnectionProperties commonProperties,
DashScopeImageProperties imageProperties, RestClient.Builder restClientBuilder,
WebClient.Builder webClientBuilder, RetryTemplate retryTemplate,
Expand All @@ -232,12 +198,9 @@ public FunctionCallbackContext springAiFunctionManager(ApplicationContext contex
return manager;
}

private record ResolvedConnectionProperties(
String baseUrl,
String apiKey,
String workspaceId,
MultiValueMap<String, String> headers
) { }
private record ResolvedConnectionProperties(String baseUrl, String apiKey, String workspaceId,
MultiValueMap<String, String> headers) {
}

private static @NotNull DashScopeAutoConfiguration.ResolvedConnectionProperties resolveConnectionProperties(
DashScopeParentProperties commonProperties, DashScopeParentProperties modelProperties, String modelType) {
Expand Down

0 comments on commit e25b59c

Please sign in to comment.