|
@@ -117,9 +117,14 @@ public class ChatService {
|
|
* @param file 文件
|
|
* @param file 文件
|
|
* @return 内容总结
|
|
* @return 内容总结
|
|
*/
|
|
*/
|
|
- public Flux<String> chatSummaryStream(String message, MultipartFile file) throws CustomException {
|
|
|
|
|
|
+ public Flux<String> chatSummaryStream(String message, MultipartFile file) {
|
|
embeddingModel.embed("");
|
|
embeddingModel.embed("");
|
|
- Tuple supportFile = isSupportFile(file);
|
|
|
|
|
|
+ Tuple supportFile;
|
|
|
|
+ try {
|
|
|
|
+ supportFile = isSupportFile(file);
|
|
|
|
+ } catch (CustomException e) {
|
|
|
|
+ return Flux.just(e.getMessage()).concatWithValues("<{完成}>");
|
|
|
|
+ }
|
|
String fileName = supportFile.get(1);
|
|
String fileName = supportFile.get(1);
|
|
String fileTypeCn = supportFile.get(2);
|
|
String fileTypeCn = supportFile.get(2);
|
|
DocumentReader reader = supportFile.get(3);
|
|
DocumentReader reader = supportFile.get(3);
|
|
@@ -148,7 +153,7 @@ public class ChatService {
|
|
* @param context 提示词
|
|
* @param context 提示词
|
|
* @return 提示词
|
|
* @return 提示词
|
|
*/
|
|
*/
|
|
- private Prompt getChatPrompt2String(String message, Message context) {
|
|
|
|
|
|
+ private Prompt getChatPrompt(String message, Message context) {
|
|
if (listMessage == null) {
|
|
if (listMessage == null) {
|
|
listMessage = new ArrayList<>();
|
|
listMessage = new ArrayList<>();
|
|
listMessage.add(new SystemMessage(userConfig.getSysMessage()));
|
|
listMessage.add(new SystemMessage(userConfig.getSysMessage()));
|
|
@@ -191,7 +196,7 @@ public class ChatService {
|
|
private Flux<String> stream(String message, Message context) {
|
|
private Flux<String> stream(String message, Message context) {
|
|
String userId = SaManager.getStpLogic("").getLoginIdAsString();
|
|
String userId = SaManager.getStpLogic("").getLoginIdAsString();
|
|
chatMessage = new StringBuffer();
|
|
chatMessage = new StringBuffer();
|
|
- Flux<ChatResponse> stream = ollamaChatModel.stream(getChatPrompt2String(message, context));
|
|
|
|
|
|
+ Flux<ChatResponse> stream = ollamaChatModel.stream(getChatPrompt(message, context));
|
|
return stream.doOnSubscribe(subscription -> this.subscription = subscription).map(
|
|
return stream.doOnSubscribe(subscription -> this.subscription = subscription).map(
|
|
response -> {
|
|
response -> {
|
|
String str = response.getResult().getOutput().getContent();
|
|
String str = response.getResult().getOutput().getContent();
|