Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit 9196cd8

Browse files
fix: 修复在无聊天记录时候出现的NPE
1 parent b0c38d9 commit 9196cd8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎src/main/java/com/gzhu/funai/service/impl/FileChatServiceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.gzhu.funai.service.impl;
22

3+
import cn.hutool.core.collection.CollUtil;
34
import com.github.benmanes.caffeine.cache.Caffeine;
45
import com.github.benmanes.caffeine.cache.LoadingCache;
56
import com.google.common.collect.ImmutableList;
@@ -337,6 +338,10 @@ private String getStandaloneQuestion(String message, Deque<SessionChatRecordEnti
337338
return null;
338339
}
339340

341+
if(CollUtil.isEmpty(windowRecords)){
342+
return String.format(qaPromptTemplate, "", message);
343+
}
344+
340345
// 获取[会话窗口]的token总数
341346
int windowRecordsTokens = windowRecordTokensCache.getOrDefault(sessionId, 0);
342347

@@ -396,7 +401,7 @@ private String getContext(String collectionName, String message, String apiKey,
396401
// 添加历史记录在最终问答
397402
int historyWindowRecordsTokens = 0;
398403
StringBuilder chatHistory = new StringBuilder();
399-
if(windowRecords != null){
404+
if(!CollUtil.isEmpty(windowRecords)){
400405

401406
// 最后一个问题不要,因为最后一个问题是刚问的
402407
windowRecords.pollLast();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /