-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Generate prompt #4395
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
Merged
Merged
fix: Generate prompt #4395
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,5 +62,3 @@ | |
|
|
||
| 输出时不得包含任何解释或附加说明,只能返回符合以上格式的内容。 | ||
|
|
||
| 智能体名称: {application_name} | ||
| 功能描述: {detail} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,12 +131,10 @@ const promptTemplates = { | |
| INIT_TEMPLATE: ` | ||
| 请根据用户描述生成一个完整的AI角色人设模板: | ||
|
|
||
| 应用名称:{application_name} | ||
| 应用描述:{detail} | ||
| 用户需求:{userInput} | ||
|
|
||
| 重要说明: | ||
| 1. 角色设定必须服务于"{application_name}"应用的核心功能 | ||
| 1. 角色设定必须服务于"{userInput}"内容设定应用的核心功能 | ||
| 2. 允许用户对角色设定的具体内容进行调整和优化 | ||
| 3. 如果用户要求修改某个技能或部分,在保持应用主题的前提下进行相应调整 | ||
|
|
||
|
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 provided code has two issues:
To address these issues, you can revise the prompt template as follows: const promptTemplates = {
INIT_TEMPLATE: `
请根据用户描述生成一个完整的AI角色人设模板:
- 应用名称:{appName}
- 应用描述:{appDesc}
用户需求:{userInput}
重要说明:
- 1. 角色设定必须服务于“${appName}”应用的核心功能。
+ 1. 角色设定必须服务于"${userInput}"内容设定应用的核心功能。
2. 允许用户对角色设定的具体内容进行调整和优化。
3. 如果用户要求修改某个技能或部分,在保持应用主题的前提下进行相应调整。
`,
};This revision ensures proper referencing using curly braces and consistency in naming conventions, which will improve usability for users interacting with this tool. |
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Your code has several issues that need to be addressed:
Variable Usage: You are referencing
applicationwithout defining it within the function scope, which will result in aNameError. Ensure thatapplicationis passed to the function and available locally.System Role Formatting: The
SYSTEM_ROLEformat string uses placeholders like{application_name}and{detail}, but these variables are not defined. If you want to use predefined values forsystem_role, define them before usingformat.Stream Call: In
process(), the stream API is called with a list of messages containing multiple roles (SystemMessage,HumanMessage,AIMessage). This might lead to incorrect formatting if they are mixed. Consider creating separate functions or classes to handle each type of message separately.Error Handling: The
get_model_instance_by_model_workspace_id()call can throw exceptions if models do not exist or are invalid. It's good practice to handle such exceptional cases more gracefully.Here’s a revised version of the code addressing some of these issues:
Key Changes:
system_roleinitialization.application.name) is correctly used.PromptGeneratorand methods).