Skip to content

Commit 9eadca5

Browse files
authored
Merge pull request #63 from springaialibaba/0228-yuluo/add-more-chatclient
feat: add playground deploy file
2 parents 57180df + 5946d6c commit 9eadca5

File tree

20 files changed

+698
-13
lines changed

20 files changed

+698
-13
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
docker/app/app.jar
2+
3+
nginx/html/assets
4+
nginx/html/index.html
5+
nginx/html/alibaba.svg

spring-ai-alibaba-integration-example/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,13 @@ pnpm dev
2929
// 如果有后端设置步骤,可以在这里补充
3030

3131
## 其他信息
32-
// 可以在这里添加关于项目的其他信息,如贡献指南、许可证等。
32+
// 可以在这里添加关于项目的其他信息,如贡献指南、许可证等。
33+
34+
## 本地 docker compose 部署启动
35+
36+
打包:make all
37+
构建镜像:make image
38+
39+
> 修改 docker/docker-compose.yml 文件的 backend image tag 为本地 build 的镜像 tag
40+
41+
启动:make run

spring-ai-alibaba-integration-example/backend/src/main/java/com/alibaba/cloud/ai/application/controller/SAABaseController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535

3636
@RestController
37-
@Tag(name = "Audio APIs")
37+
@Tag(name = "Base APIs")
3838
@RequestMapping("/api/v1/")
3939
public class SAABaseController {
4040

@@ -56,4 +56,10 @@ public Result<Set<Map<String, String>>> getDashScopeModels() {
5656
return Result.success(dashScope);
5757
}
5858

59+
@GetMapping("/health")
60+
public Result<String> health() {
61+
62+
return Result.success("Spring AI Aliabba Playground is running......");
63+
}
64+
5965
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.alibaba.cloud.ai.application.controller;
2+
3+
import com.alibaba.cloud.ai.application.entity.result.Result;
4+
import com.alibaba.cloud.ai.application.service.SAAWebSearch;
5+
import io.swagger.v3.oas.annotations.tags.Tag;
6+
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RequestMapping;
9+
import org.springframework.web.bind.annotation.RequestParam;
10+
import org.springframework.web.bind.annotation.RestController;
11+
12+
/**
13+
* @author yuluo
14+
* @author <a href="mailto:yuluo08290126@gmail.com">yuluo</a>
15+
*/
16+
17+
@RestController
18+
@Tag(name = "Web Search APIs")
19+
@RequestMapping("/api/v1/")
20+
public class SAAWebSearchController {
21+
22+
private final SAAWebSearch webSearch;
23+
24+
public SAAWebSearchController(SAAWebSearch webSearch) {
25+
this.webSearch = webSearch;
26+
}
27+
28+
@GetMapping("/search")
29+
public Result<Object> search(
30+
@RequestParam(value = "query", required = true) String query
31+
) {
32+
33+
return Result.success(webSearch.search(query));
34+
}
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.alibaba.cloud.ai.application.service;
2+
3+
import org.springframework.stereotype.Service;
4+
5+
/**
6+
* @author yuluo
7+
* @author <a href="mailto:yuluo08290126@gmail.com">yuluo</a>
8+
*/
9+
10+
@Service
11+
public class SAAWebSearch {
12+
13+
// private final GoogleSearchEngine googleSearchEngine;
14+
15+
// public SAAWebSearch(GoogleSearchEngine googleSearchEngine) {
16+
// this.googleSearchEngine = googleSearchEngine;
17+
// }
18+
19+
public Object search(String query) {
20+
21+
// return googleSearchEngine.search(query);
22+
return null;
23+
}
24+
25+
}

spring-ai-alibaba-integration-example/backend/src/main/resources/application-dev.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ spring:
2020
dashscope:
2121
api-key: ${AI_DASHSCOPE_API_KEY}
2222

23-
retry:
24-
timeout:
25-
max-attempts: 3
26-
2723
datasource:
2824
url: jdbc:sqlite:src/main/resources/db/user.db
2925
driver-class-name: org.sqlite.JDBC
@@ -39,3 +35,6 @@ spring:
3935
hibernate:
4036
boot:
4137
allow_jdbc_metadata_access: false
38+
39+
web-search:
40+
api-key: ${WEB_SEARCH_API_KEY}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
spring:
19+
ai:
20+
dashscope:
21+
api-key: ${AI_DASHSCOPE_API_KEY}
22+
23+
datasource:
24+
url: jdbc:sqlite:/app/user.db
25+
driver-class-name: org.sqlite.JDBC
26+
27+
jpa:
28+
show-sql: true
29+
database-platform: org.hibernate.community.dialect.SQLiteDialect
30+
31+
hibernate:
32+
ddl-auto: create-drop
33+
34+
properties:
35+
hibernate:
36+
boot:
37+
allow_jdbc_metadata_access: false
38+
39+
web-search:
40+
api-key: ${WEB_SEARCH_API_KEY}

spring-ai-alibaba-integration-example/backend/src/main/resources/application-pord.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,23 @@
1818
spring:
1919
ai:
2020
dashscope:
21-
api-key: 1234xxxx
21+
api-key: ${AI_DASHSCOPE_API_KEY}
2222

2323
datasource:
2424
url: jdbc:sqlite:src/main/resources/db/user.db
2525
driver-class-name: org.sqlite.JDBC
2626

2727
jpa:
28-
hibernate:
29-
ddl-auto: update
3028
show-sql: true
29+
database-platform: org.hibernate.community.dialect.SQLiteDialect
30+
31+
hibernate:
32+
ddl-auto: create-drop
33+
3134
properties:
3235
hibernate:
33-
dialect: org.sqlite.hibernate.dialect.SQLiteDialect
36+
boot:
37+
allow_jdbc_metadata_access: false
38+
39+
web-search:
40+
api-key: ${WEB_SEARCH_API_KEY}

spring-ai-alibaba-integration-example/backend/src/main/resources/logback-spring.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@
121121
</root>
122122
</springProfile>
123123

124+
<springProfile name="docker">
125+
<root level="INFO">
126+
<appender-ref ref="ConsoleAppender"/>
127+
<appender-ref ref="SystemOutFileAppender"/>
128+
<appender-ref ref="ErrOutFileAppender"/>
129+
</root>
130+
</springProfile>
131+
124132
<!-- Development environment configuration -->
125133
<springProfile name="mysql">
126134
<root level="INFO">
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 使用指定的基础镜像
2+
FROM registry.cn-hangzhou.aliyuncs.com/yuluo-yx/java-base:V20240116
3+
4+
# 设置工作目录
5+
WORKDIR /app
6+
7+
# 将当前目录下的 backend.jar 复制到镜像中的 /app 目录
8+
COPY ./docker/app/app.jar /app/app.jar
9+
10+
# 设置容器启动时执行的命令
11+
ENTRYPOINT ["java", "-jar", "/app/app.jar", "--spring.profiles.active=docker"]

0 commit comments

Comments
 (0)