-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Improve prompt #4027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Improve prompt #4027
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,7 @@ const chatMessages = ref<Array<any>>([]) | |
| // 原始输入 | ||
| const originalUserInput = ref<string>('') | ||
| const modelID = ref('') | ||
| const applicationID = ref('') | ||
| const dialogVisible = ref(false) | ||
| const inputValue = ref<string>('') | ||
| const loading = ref<boolean>(false) | ||
|
|
@@ -97,8 +98,8 @@ const promptTemplates = { | |
|
|
||
| 请按以下格式生成: | ||
|
|
||
| # 角色: 角色名称 | ||
| 角色概述和主要职责的一句话描述 | ||
| # 角色: | ||
|
|
||
|
|
||
| ## 目标: | ||
| 角色的工作目标,如果有多目标可以分点列出,但建议更聚焦1-2个目标 | ||
|
|
@@ -118,9 +119,12 @@ const promptTemplates = { | |
|
|
||
|
|
||
| ## 限制: | ||
| 描述角色在互动过程中需要遵循的限制条件1 | ||
| 描述角色在互动过程中需要遵循的限制条件2 | ||
| 描述角色在互动过程中需要遵循的限制条件3 | ||
| 1. **严格限制回答范围**:仅回答与角色设定相关的问题。 | ||
| - 如果用户提问与角色无关,必须使用以下固定格式回复: | ||
| “对不起,我只能回答与【角色设定】相关的问题,您的问题不在服务范围内。” | ||
| - 不得提供任何与角色设定无关的回答。 | ||
| 2. 描述角色在互动过程中需要遵循的限制条件2 | ||
| 3. 描述角色在互动过程中需要遵循的限制条件3 | ||
| `, | ||
| } | ||
|
|
||
|
|
@@ -200,7 +204,7 @@ function generatePrompt(inputValue: any) { | |
| messages: chatMessages.value, | ||
| prompt: promptTemplates.INIT_TEMPLATE, | ||
| } | ||
| generatePromptAPI.generate_prompt(workspaceId, modelID.value, requestData).then((response) => { | ||
| generatePromptAPI.generate_prompt(workspaceId, modelID.value, applicationID.value,requestData).then((response) => { | ||
| const reader = response.body.getReader() | ||
| reader.read().then(getWrite(reader)) | ||
| }) | ||
|
|
@@ -226,8 +230,9 @@ const stopChat = () => { | |
| chatMessages.value = [] | ||
| } | ||
|
|
||
| const open = (modelId: string) => { | ||
| const open = (modelId: string, applicationId: string) => { | ||
| modelID.value = modelId | ||
| applicationID.value = applicationId | ||
| dialogVisible.value = true | ||
| originalUserInput.value = '' | ||
| chatMessages.value = [] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no identified irregularities, potential issues, or optimization suggestions in the provided code snippet. The changes introduced to include |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,8 @@ class IntentNode extends AppNode { | |
| } | ||
| } | ||
|
|
||
| const get_up_index_height = (branch_lsit: Array<any>, index: number) => { | ||
| return branch_lsit | ||
| const get_up_index_height = (branch_list: Array<any>, index: number) => { | ||
| return branch_list | ||
| .filter((item, i) => i < index) | ||
| .map((item) => item.height + 8) | ||
| .reduce((x,y) => x+y, 0) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function -const get_up_index_height = (branch_lsit: Array<any>, index: number) => {
+const get_up_index_height = (branch_list: Array<any>, index: number) => {This should have no effect on its functionality. Optimization Suggestions: There isn't much that could significantly optimize this function in terms of performance with the current implementation. The operations involved—filtering, mapping, and reducing—are already quite efficient for small arrays. If you anticipate dealing with very large datasets, consider parallelizing some parts of the code if it's applicable, although in most cases JavaScript engines will handle such tasks internally efficiently. Ensure that all other functions used within |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code snippet has a couple of issues:
Incorrect URL Construction: The original line constructs the URL in the incorrect form.
Should be:
Missing Return Type Annotation for
generate_prompt: Although typescript annotations are optional, it's considered good practice to include them for clarity.Unnecessary Use of Window Object: Assuming
window.MaxKB?.prefixis defined elsewhere, usingWindowGlobalScopemight be more appropriate depending on how you want this logic scoped.Here is corrected and improved version:
Note that I also used
fetch()instead ofpostStream()which is a hypothetical utility function you may need to define to match your implementation details. Also ensure all imports likeRef,Result, etc., should be correctly resolved by their respective module names.