Skip to content

Commit

Permalink
handle more case for different finish reason (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangtianyu authored Oct 30, 2024
1 parent 475412a commit b452df7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/messages/devpilot_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
devpilot.settings.methodShortcutGroupDisplay=Group

devpilot.notification.stop.length=Devpilot terminated due to exceeding length.
devpilot.notification.stop.filterContent=Devpilot terminated due to content filter.
13 changes: 8 additions & 5 deletions src/main/resources/messages/devpilot_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
completion.apply.partial.tooltips=\u9010\u884C\u91C7\u7EB3

0 comments on commit b452df7

Please sign in to comment.