-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.xywenjie.spring-ai-extension</groupId> | ||
<artifactId>spring-ai-extension</artifactId> | ||
<version>0.8.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>spring-ai-spring-boot-autoconfigure</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Spring AI Spring Boot Auto Configure</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.xywenjie.spring-ai-extension</groupId> | ||
<artifactId>spring-ai-dashscope</artifactId> | ||
<version>${project.parent.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
</project> |
22 changes: 22 additions & 0 deletions
22
...rg/springframework/ai/autoconfigure/dashscope/DashsCopeAliyunConnectionConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.springframework.ai.autoconfigure.dashscope; | ||
|
||
import org.springframework.ai.dashscope.DashsCopeService; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.util.StringUtils; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties({DashsCopeAliyunConnectionProperties.class}) | ||
public class DashsCopeAliyunConnectionConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public DashsCopeService dashsCopeService(DashsCopeAliyunConnectionProperties connectionProperties){ | ||
if(StringUtils.hasText(connectionProperties.getAccessToken())){ | ||
return new DashsCopeService(connectionProperties.getAccessToken()); | ||
} | ||
return new DashsCopeService(System.getenv("DASHSCOPE_API_KEY")); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...a/org/springframework/ai/autoconfigure/dashscope/DashsCopeAliyunConnectionProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.springframework.ai.autoconfigure.dashscope; | ||
|
||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(DashsCopeAliyunConnectionProperties.CONFIG_PREFIX) | ||
public class DashsCopeAliyunConnectionProperties { | ||
|
||
public static final String CONFIG_PREFIX = "spring.ai.dashscope.aliyun"; | ||
|
||
private String accessToken; | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
public void setAccessToken(String accessToken) { | ||
this.accessToken = accessToken; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...g/springframework/ai/autoconfigure/dashscope/qwen/DashsCopeQwenChatAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.springframework.ai.autoconfigure.dashscope.qwen; | ||
|
||
import org.springframework.ai.dashscope.DashsCopeService; | ||
import org.springframework.ai.dashscope.qwen.QWenChatClient; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@AutoConfiguration | ||
@EnableConfigurationProperties({DashsCopeQwenChatProperties.class}) | ||
public class DashsCopeQwenChatAutoConfiguration { | ||
|
||
@Bean | ||
public QWenChatClient qWenChatClient(DashsCopeService dashsCopeService){ | ||
return new QWenChatClient(dashsCopeService); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...java/org/springframework/ai/autoconfigure/dashscope/qwen/DashsCopeQwenChatProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.springframework.ai.autoconfigure.dashscope.qwen; | ||
|
||
import org.springframework.ai.dashscope.metadata.support.ChatModel; | ||
import org.springframework.ai.dashscope.qwen.QWenChatOptions; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.NestedConfigurationProperty; | ||
|
||
@ConfigurationProperties(DashsCopeQwenChatProperties.CONFIG_PREFIX) | ||
public class DashsCopeQwenChatProperties { | ||
|
||
public static final String CONFIG_PREFIX = "spring.ai.dashscope.qwen.chat"; | ||
|
||
private String model = ChatModel.QWen_72B_CHAT.getModelValue(); | ||
|
||
@NestedConfigurationProperty | ||
private QWenChatOptions options = QWenChatOptions.builder().build(); | ||
|
||
public String getModel() { | ||
return model; | ||
} | ||
|
||
public void setModel(String model) { | ||
this.model = model; | ||
} | ||
|
||
public QWenChatOptions getOptions() { | ||
return options; | ||
} | ||
|
||
public void setOptions(QWenChatOptions options) { | ||
this.options = options; | ||
} | ||
} |