fix: knowledgeBase ownerUuid

This commit is contained in:
moyangzhan 2024-04-22 19:04:25 +08:00
parent 35fd989512
commit 5bfc673070
4 changed files with 23 additions and 12 deletions

View File

@ -99,7 +99,6 @@ Google的配置
update adi_sys_config set value = '{"url":"https://www.googleapis.com/customsearch/v1","key":"my key from cloud.google.com","cx":"my cx from programmablesearchengine.google.com"}' where name = 'google_setting';
```
**b. 修改配置文件**
* postgresql: application-[dev|prod].xml中的spring.datasource
@ -125,8 +124,8 @@ mvn clean package -Dmaven.test.skip=true
a. jar包启动
```plaintext
cd adi-bootstrap/target
nohup java -jar -Xms768m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError adi-chat-0.0.1-SNAPSHOT.jar --spring.profiles.active=[dev|prod] dev/null 2>&1 &
adi-bootstrap-0.0.1-SNAPSHOT.jarcd adi-bootstrap/target
nohup java -jar -Xms768m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError adi-bootstrap-0.0.1-SNAPSHOT.jar --spring.profiles.active=[dev|prod] dev/null 2>&1 &
```
b. docker启动
@ -143,7 +142,7 @@ docker run -d \
## 待办:
增强RAG
高级RAG
增加搜索引擎BING、百度

View File

@ -117,14 +117,10 @@ public abstract class AbstractLLMService<T> {
}
TokenStream tokenStream;
if (StringUtils.isNotBlank(params.getMessageId()) && StringUtils.isNotBlank(params.getSystemMessage())) {
tokenStream = chatAssistant.chat(params.getMessageId(), params.getSystemMessage(), params.getUserMessage());
} else if (StringUtils.isNotBlank(params.getMessageId()) && StringUtils.isBlank(params.getSystemMessage())) {
tokenStream = chatAssistant.chat(params.getMessageId(), params.getUserMessage());
} else if (StringUtils.isBlank(params.getMessageId()) && StringUtils.isNotBlank(params.getSystemMessage())) {
tokenStream = chatAssistantWithoutMemory.chat(params.getSystemMessage(), params.getUserMessage());
if (StringUtils.isNotBlank(params.getMessageId())) {
tokenStream = chatWithMemory(params.getMessageId(), params.getSystemMessage(), params.getUserMessage());
} else {
tokenStream = chatAssistantWithoutMemory.chat(params.getUserMessage());
tokenStream = chatWithoutMemory(params.getSystemMessage(), params.getUserMessage());
}
tokenStream
.onNext((content) -> {
@ -170,4 +166,19 @@ public abstract class AbstractLLMService<T> {
.start();
}
public TokenStream chatWithoutMemory(String systemMessage, String userMessage) {
if (StringUtils.isNotBlank(systemMessage)) {
return chatAssistantWithoutMemory.chat(systemMessage, userMessage);
} else {
return chatAssistantWithoutMemory.chat(userMessage);
}
}
public TokenStream chatWithMemory(String messageId, String systemMessage, String userMessage) {
if (StringUtils.isNotBlank(systemMessage)) {
return chatAssistant.chat(messageId, systemMessage, userMessage);
} else {
return chatAssistant.chat(messageId, userMessage);
}
}
}

View File

@ -93,6 +93,7 @@ public class KnowledgeBaseService extends ServiceImpl<KnowledgeBaseMapper, Knowl
uuid = UUID.randomUUID().toString().replace("-", "");
knowledgeBase.setUuid(uuid);
knowledgeBase.setOwnerId(user.getId());
knowledgeBase.setOwnerUuid(user.getUuid());
knowledgeBase.setOwnerName(user.getName());
baseMapper.insert(knowledgeBase);
} else {

View File

@ -127,7 +127,7 @@ public class RAGService {
double minScore = 0.6;
List<EmbeddingMatch<TextSegment>> relevantEmbeddings = ((AdiPgVectorEmbeddingStore) embeddingStore).findRelevantByMetadata(metadataCond, questionEmbedding, maxResults, minScore);
// Create a prompt for the model that includes question and relevant embeddings
// Create a prompt that includes question and relevant embeddings
String information = relevantEmbeddings.stream()
.map(match -> match.embedded().text())
.collect(joining("\n\n"));