Skip to content

Commit f0cb1e2

Browse files
committed
fix: Remove Alibailian related code
1 parent bdaf93f commit f0cb1e2

File tree

107 files changed

+0
-14200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+0
-14200
lines changed

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ COPY --from=build /app/base/target/tiny-engine-base-*.jar /app/tiny-engine-base.
1717
COPY --from=build /app/documents /app/documents
1818
COPY --from=build /app/all-MiniLM-L6-v2 /app/all-MiniLM-L6-v2
1919
# 设置环境变量
20-
ENV ACCESS_KEY_ID=""
21-
ENV ACCESS_KEY_SECRET=""
22-
ENV INDEX_ID=""
23-
ENV WORK_SPACE_ID=""
2420
ENV FOLDER_PATH="/app/documents"
2521
# 替换为自己的域名接口路径
2622
ENV TINY_ENGINE_URL="https://agent.opentiny.design/material-center/api/resource/download"

base/src/main/java/com/tinyengine/it/controller/AiChatController.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
package com.tinyengine.it.controller;
1414

15-
import com.tinyengine.it.common.base.Result;
1615
import com.tinyengine.it.common.log.SystemControllerLog;
1716
import com.tinyengine.it.model.dto.ChatRequest;
1817

19-
import com.tinyengine.it.model.dto.NodeDto;
2018
import com.tinyengine.it.service.app.v1.AiChatV1Service;
2119
import io.swagger.v3.oas.annotations.Operation;
2220
import io.swagger.v3.oas.annotations.Parameter;
@@ -124,24 +122,4 @@ public ResponseEntity<?> completions(@RequestBody ChatRequest request,
124122
.body(e.getMessage());
125123
}
126124
}
127-
128-
/**
129-
* AI search api
130-
*
131-
* @param content the AI search param
132-
* @return ai回答信息 result
133-
*/
134-
@Operation(summary = "搜索知识库", description = "搜索知识库",
135-
parameters = {
136-
@Parameter(name = "content", description = "入参对象")
137-
}, responses = {
138-
@ApiResponse(responseCode = "200", description = "返回信息",
139-
content = @Content(mediaType = "application/json", schema = @Schema())),
140-
@ApiResponse(responseCode = "400", description = "请求失败")
141-
})
142-
@SystemControllerLog(description = "AI serarch api")
143-
@PostMapping("/ai/search")
144-
public Result<List<NodeDto>> search(@RequestBody String content) throws Exception {
145-
return aiChatV1Service.chatSearch(content);
146-
}
147125
}

base/src/main/java/com/tinyengine/it/service/app/impl/v1/AiChatV1ServiceImpl.java

Lines changed: 0 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,12 @@
1212

1313
package com.tinyengine.it.service.app.impl.v1;
1414

15-
import com.aliyun.bailian20231229.Client;
16-
import com.aliyun.tea.TeaException;
17-
import com.aliyun.teaopenapi.models.Config;
18-
import com.aliyun.teaopenapi.models.OpenApiRequest;
19-
import com.aliyun.teaopenapi.models.Params;
20-
import com.aliyun.teautil.models.RuntimeOptions;
2115
import com.fasterxml.jackson.databind.JsonNode;
22-
import com.tinyengine.it.common.base.Result;
2316
import com.tinyengine.it.common.log.SystemServiceLog;
2417
import com.tinyengine.it.common.utils.JsonUtils;
2518
import com.tinyengine.it.config.OpenAIConfig;
2619
import com.tinyengine.it.model.dto.ChatRequest;
27-
import com.tinyengine.it.model.dto.NodeDto;
2820
import com.tinyengine.it.service.app.v1.AiChatV1Service;
29-
import org.slf4j.Logger;
30-
import org.slf4j.LoggerFactory;
3121
import org.springframework.stereotype.Service;
3222
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
3323

@@ -39,9 +29,7 @@
3929
import java.net.http.HttpResponse;
4030
import java.nio.charset.StandardCharsets;
4131
import java.time.Duration;
42-
import java.util.ArrayList;
4332
import java.util.HashMap;
44-
import java.util.List;
4533
import java.util.Map;
4634

4735
/**
@@ -51,13 +39,7 @@
5139
*/
5240
@Service
5341
public class AiChatV1ServiceImpl implements AiChatV1Service {
54-
private static final String ACCESS_KEY_ID = System.getenv("ACCESS_KEY_ID");
55-
private static final String ACCESS_KEY_SECRET = System.getenv("ACCESS_KEY_SECRET");
56-
private static final String ENDPOINT = "bailian.cn-beijing.aliyuncs.com";
57-
private static final String INDEX_ID = System.getenv("INDEX_ID");
58-
private static final String WORK_SPACE_ID = System.getenv("WORK_SPACE_ID");
5942
private final OpenAIConfig config = new OpenAIConfig();
60-
private static final Logger log = LoggerFactory.getLogger(AiChatV1ServiceImpl.class);
6143
private HttpClient httpClient = HttpClient.newBuilder()
6244
.connectTimeout(Duration.ofSeconds(config.getTimeoutSeconds()))
6345
.build();
@@ -122,160 +104,6 @@ private String ensureUrlProtocol(String url) {
122104
return "https://" + url;
123105
}
124106

125-
/**
126-
* 创建客户端
127-
*/
128-
private Client createClient() throws Exception {
129-
return new Client(new Config()
130-
.setAccessKeyId(ACCESS_KEY_ID)
131-
.setAccessKeySecret(ACCESS_KEY_SECRET)
132-
.setEndpoint(ENDPOINT)
133-
.setEndpointType("access_key"));
134-
}
135-
136-
/**
137-
* 创建API信息
138-
*/
139-
private Params createApiInfo(String WorkspaceId) throws Exception {
140-
return new Params()
141-
// 接口名称
142-
.setAction("Retrieve")
143-
// 接口版本
144-
.setVersion("2023-12-29")
145-
// 接口协议
146-
.setProtocol("HTTPS")
147-
// 接口 HTTP 方法
148-
.setMethod("POST")
149-
.setAuthType("AK")
150-
.setStyle("ROA")
151-
// 接口 PATH
152-
.setPathname("/" + com.aliyun.openapiutil.Client.getEncodeParam(WorkspaceId) + "/index/retrieve")
153-
// 接口请求体内容格式
154-
.setReqBodyType("json")
155-
// 接口响应体内容格式
156-
.setBodyType("json");
157-
}
158-
159-
/**
160-
* 安全类型转换工具方法
161-
*/
162-
private <T> T safeCast(Object obj, Class<T> clazz, T defaultValue) {
163-
if (obj == null) {
164-
return defaultValue;
165-
}
166-
try {
167-
return clazz.cast(obj);
168-
} catch (ClassCastException e) {
169-
log.warn("类型转换失败: {} 无法转换为 {}", obj.getClass().getName(), clazz.getName());
170-
return defaultValue;
171-
}
172-
}
173-
174-
private String safeCastToString(Object obj) {
175-
return safeCast(obj, String.class, "");
176-
}
177-
178-
private Double safeCastToDouble(Object obj) {
179-
return safeCast(obj, Double.class, 0.0);
180-
}
181-
182-
private Long safeCastToLong(Object obj) {
183-
return safeCast(obj, Long.class, 0L);
184-
}
185-
186-
/**
187-
* chatSearch.
188-
*
189-
* @param content the content
190-
* @return String the String
191-
*/
192-
public Result chatSearch(String content) {
193-
try {
194-
Client client = createClient();
195-
Params params = createApiInfo(WORK_SPACE_ID);
196-
197-
Map<String, Object> queries = new HashMap<>();
198-
queries.put("IndexId", INDEX_ID);
199-
queries.put("Query", content);
200-
queries.put("EnableRewrite", "true");
201-
202-
RuntimeOptions runtime = new RuntimeOptions();
203-
OpenApiRequest request = new OpenApiRequest()
204-
.setQuery(com.aliyun.openapiutil.Client.query(queries));
205-
206-
Map<String, ?> response = client.callApi(params, request, runtime);
207-
Map<String, Object> body = (Map<String, Object>) response.get("body");
208-
209-
if (body == null) {
210-
return Result.failed("响应体为空");
211-
}
212-
213-
long status = safeCastToLong(body.get("Status"));
214-
if (status != 200L) {
215-
String message = safeCastToString(body.get("Message"));
216-
log.error("搜索失败: status={}, message={}", status, message);
217-
return Result.failed("搜索失败: " + message);
218-
}
219-
220-
Map data = safeCast(body.get("Data"), Map.class, new HashMap<>());
221-
if (data == null || data.isEmpty()) {
222-
return Result.success(new ArrayList<>());
223-
}
224-
225-
List nodes = safeCast(data.get("Nodes"), List.class, new ArrayList<>());
226-
if (nodes.isEmpty()) {
227-
return Result.success(new ArrayList<>());
228-
}
229-
230-
List nodeDtos = convertToNodeDtos(nodes);
231-
return Result.success(nodeDtos);
232-
233-
} catch (TeaException e) {
234-
log.error("阿里云Tea异常: {}", e.getMessage(), e);
235-
return Result.failed("阿里云服务异常: " + e.getMessage());
236-
} catch (Exception e) {
237-
log.error("搜索异常: {}", e.getMessage(), e);
238-
return Result.failed("系统异常: " + e.getMessage());
239-
}
240-
}
241-
242-
/**
243-
* 转换节点数据
244-
*/
245-
private List<NodeDto> convertToNodeDtos(List<Map<String, Object>> nodes) {
246-
List<NodeDto> nodeDtos = new ArrayList<>();
247-
248-
for (Map<String, Object> node : nodes) {
249-
try {
250-
NodeDto nodeDto = new NodeDto();
251-
252-
// 安全获取文本内容
253-
nodeDto.setContent(safeCastToString(node.get("Text")));
254-
255-
// 安全获取分数
256-
Object scoreObj = node.get("Score");
257-
if (scoreObj instanceof Number) {
258-
nodeDto.setScore(((Number) scoreObj).doubleValue());
259-
} else {
260-
nodeDto.setScore(safeCastToDouble(scoreObj));
261-
}
262-
263-
// 安全获取元数据
264-
Map metadata = safeCast(node.get("Metadata"), Map.class, new HashMap<>());
265-
if (metadata != null) {
266-
nodeDto.setDocName(safeCastToString(metadata.get("doc_name")));
267-
}
268-
269-
nodeDtos.add(nodeDto);
270-
271-
} catch (Exception e) {
272-
log.warn("节点数据转换失败: {}", e.getMessage());
273-
}
274-
}
275-
276-
return nodeDtos;
277-
}
278-
279107
private String buildRequestBody(ChatRequest request) {
280108
Map<String, Object> body = new HashMap<>();
281109
body.put("model", request.getModel() != null ? request.getModel() : config.getDefaultModel());

base/src/main/java/com/tinyengine/it/service/app/v1/AiChatV1Service.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212

1313
package com.tinyengine.it.service.app.v1;
1414

15-
import com.tinyengine.it.common.base.Result;
1615
import com.tinyengine.it.model.dto.ChatRequest;
17-
import com.tinyengine.it.model.dto.NodeDto;
18-
19-
import java.util.List;
2016

2117
/**
2218
* The interface AIChat v 1 service.
@@ -31,12 +27,4 @@ public interface AiChatV1Service {
3127
* @return Object the Object
3228
*/
3329
public Object chatCompletion(ChatRequest request) throws Exception;
34-
35-
/**
36-
* chatSearch.
37-
*
38-
* @param content the content
39-
* @return String the String
40-
*/
41-
public Result<List<NodeDto>> chatSearch(String content) throws Exception;
4230
}

documents/tinyengine/about-applications/create-application-blank-or-template.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

documents/tinyengine/about-applications/develop-application.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

documents/tinyengine/about-designer/create-designer.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

documents/tinyengine/about-designer/customize-designer.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

documents/tinyengine/about-designer/customize-material-package-themes-dsl-toolbar-plugins.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

documents/tinyengine/about-designer/designer-intro.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)