Skip to content

Commit

Permalink
enable local storage for oss
Browse files Browse the repository at this point in the history
  • Loading branch information
TyCoding committed Aug 31, 2024
1 parent da1bfab commit ffdc9a6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package cn.tycoding.langchat;

import cn.tycoding.langchat.common.oss.EnableFileStorage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
Expand All @@ -24,6 +25,7 @@
* @author tycoding
* @since 2024/2/4
*/
@EnableFileStorage
@EnableAsync
@SpringBootApplication
public class LangChatApp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public R reEmbed(@PathVariable String docsId) {
}
if (EmbedConst.ORIGIN_TYPE_UPLOAD.equals(docs.getType())) {
// clear before re-embed
embeddingService.clearDocSlicesOfDoc(docsId);
embeddingService.clearDocSlices(docsId);
embeddingService.embedDocsSlice(docs, docs.getUrl());
TaskManager.submitTask(userId,
Executors.callable(() -> embeddingService.embedDocsSlice(docs, docs.getUrl())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@
*/
public interface EmbeddingService {

/**
* 删除文档已有切片
*
* @param docsId 文档id
* @return true:已删除切片;false:切片删除失败
*/
void clearDocSlicesOfDoc(String docsId);
void clearDocSlices(String docsId);

void embedDocsSlice(AigcDocs data, String url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ public class EmbeddingServiceImpl implements EmbeddingService {

@Override
@Transactional
public void clearDocSlicesOfDoc(String docsId) {
public void clearDocSlices(String docsId) {
if (StrUtil.isBlank(docsId)) {
return;
}
// remove from embedding store
List<String> vectorIds = aigcKnowledgeService.listSliceVectorIdsOfDoc(docsId);
if (vectorIds.isEmpty()) {
return;
}
embeddingStore.removeAll(vectorIds);
// remove from docSlice
aigcKnowledgeService.removeSlicesOfDoc(docsId);
Expand Down
6 changes: 3 additions & 3 deletions langchat-server/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ langchat:
oss:
default-platform: local
qiniu-kodo:
- platform: qiniu # 存储平台标识
- platform: qiniu # 存储平台标识,七牛:qiniu、阿里OSS:aliyun-oss、腾讯OSS:tencent-cos
enable-storage: true # 启用存储
access-key: <ak>
secret-key: <sk>
Expand All @@ -40,8 +40,8 @@ langchat:
enable-access: true #启用访问(线上请使用 Nginx 配置,效率更高)
domain: http://127.0.0.1/ # 访问域名,例如:“http://127.0.0.1:8030/file/”,注意后面要和 path-patterns 保持一致,“/”结尾,本地存储建议使用相对路径,方便后期更换域名
base-path: langchat/ # 基础路径
path-patterns: /Users/tycoding/data/software/nginx/ # 访问路径
storage-path: /Users/tycoding/data/software/nginx/ # 存储路径
path-patterns: /static/** # 访问路径(默认本地target目录),注意:如果使用本地nginx容器,此路径要修改为nginx存储路径
storage-path: ./static/ # 存储路径(默认本地target目录),注意:如果使用本地nginx容器,此路径要修改为nginx存储路径
auth:
# client端新注册的用户是否开启操作权限,如果为false,client端新用户默认只有页面预览权限没有操作权限
# 需要在server端给指定用户授权后才能正常使用
Expand Down
Binary file not shown.

0 comments on commit ffdc9a6

Please sign in to comment.