diff --git a/src/main/java/com/zhongan/devpilot/integrations/llms/LlmProvider.java b/src/main/java/com/zhongan/devpilot/integrations/llms/LlmProvider.java index 0e1c29a..1396a3f 100644 --- a/src/main/java/com/zhongan/devpilot/integrations/llms/LlmProvider.java +++ b/src/main/java/com/zhongan/devpilot/integrations/llms/LlmProvider.java @@ -21,6 +21,7 @@ import java.util.function.Consumer; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -115,7 +116,18 @@ public void onEvent(@NotNull EventSource eventSource, @Nullable String id, @Null if (choice.getDelta().getContent() != null) { result.append(choice.getDelta().getContent()); } - streaming = !"stop".equals(finishReason); + + if (!StringUtils.isEmpty(finishReason)) { + streaming = Boolean.FALSE; + + if (finishReason.contains("length")) { + DevPilotNotification.info(DevPilotMessageBundle.get("devpilot.notification.stop.length")); + } + + if (finishReason.contains("content_filter")) { + DevPilotNotification.info(DevPilotMessageBundle.get("devpilot.notification.stop.filterContent")); + } + } } RecallModel recallModel = null; diff --git a/src/main/resources/messages/devpilot_en.properties b/src/main/resources/messages/devpilot_en.properties index d128dc5..e607d61 100644 --- a/src/main/resources/messages/devpilot_en.properties +++ b/src/main/resources/messages/devpilot_en.properties @@ -101,4 +101,7 @@ completion.apply.partial.tooltips=Accept by line devpilot.settings.methodShortcutDisplayModeLabel=Method Shortcut Display Mode devpilot.settings.methodShortcutHidden=Hidden devpilot.settings.methodShortcutInlineDisplay=Inline -devpilot.settings.methodShortcutGroupDisplay=Group \ No newline at end of file +devpilot.settings.methodShortcutGroupDisplay=Group + +devpilot.notification.stop.length=Devpilot terminated due to exceeding length. +devpilot.notification.stop.filterContent=Devpilot terminated due to content filter. \ No newline at end of file diff --git a/src/main/resources/messages/devpilot_zh.properties b/src/main/resources/messages/devpilot_zh.properties index 8a12fe6..7f110a5 100644 --- a/src/main/resources/messages/devpilot_zh.properties +++ b/src/main/resources/messages/devpilot_zh.properties @@ -94,9 +94,12 @@ devpilot.notification.network.setting=\u72B6\u6001\u68C0\u67E5\u914D\u7F6E devpilot.notification.version.message=DevPilot\u7248\u672C\u592A\u4F4E, \u8BF7\u5347\u7EA7\u7248\u672C devpilot.notification.upgrade.message=\u53BB\u5347\u7EA7\u63D2\u4EF6 -completion.apply.partial.tooltips=\u9010\u884C\u91C7\u7EB3 +devpilot.settings.methodShortcutDisplayModeLabel=\u65b9\u6cd5\u5feb\u6377\u952e\u663e\u793a\u65b9\u5f0f +devpilot.settings.methodShortcutHidden=\u4e0d\u663e\u793a +devpilot.settings.methodShortcutInlineDisplay=\u5e73\u94fa +devpilot.settings.methodShortcutGroupDisplay=\u5206\u7ec4\u4e0b\u62c9 + +devpilot.notification.stop.length=Devpilot\u8d85\u51fa\u957f\u5ea6\u800c\u7ec8\u6b62. +devpilot.notification.stop.filterContent=Devpilot\u8fc7\u6ee4\u4e86\u6b64\u5185\u5bb9. -devpilot.settings.methodShortcutDisplayModeLabel=\u65B9\u6CD5\u5FEB\u6377\u952E\u663E\u793A\u65B9\u5F0F -devpilot.settings.methodShortcutHidden=\u4E0D\u663E\u793A -devpilot.settings.methodShortcutInlineDisplay=\u5E73\u94FA -devpilot.settings.methodShortcutGroupDisplay=\u5206\u7EC4\u4E0B\u62C9 \ No newline at end of file +completion.apply.partial.tooltips=\u9010\u884C\u91C7\u7EB3