fix: Generate prompt

This commit is contained in:
zhangzhanwei 2025-11-27 18:18:50 +08:00 committed by zhanweizhang7
parent a05335a0b3
commit d9ecf8cc9c
3 changed files with 2 additions and 10 deletions

View File

@ -173,8 +173,6 @@ class PromptGenerateSerializer(serializers.Serializer):
message = messages[-1]['content']
q = prompt.replace("{userInput}", message)
q = q.replace("{application_name}", application.name)
q = q.replace("{detail}", application.desc)
messages[-1]['content'] = q
SUPPORTED_MODEL_TYPES = ["LLM", "IMAGE"]
@ -185,13 +183,11 @@ class PromptGenerateSerializer(serializers.Serializer):
if not model_exist:
raise Exception(_("Model does not exists or is not an LLM model"))
system_content = SYSTEM_ROLE.format(application_name=application.name, detail=application.desc)
def process():
model = get_model_instance_by_model_workspace_id(model_id=model_id, workspace_id=workspace_id,
**application.model_params_setting)
try:
for r in model.stream([SystemMessage(content=system_content),
for r in model.stream([SystemMessage(content=SYSTEM_ROLE),
*[HumanMessage(content=m.get('content')) if m.get(
'role') == 'user' else AIMessage(
content=m.get('content')) for m in messages]]):

View File

@ -62,5 +62,3 @@
输出时不得包含任何解释或附加说明,只能返回符合以上格式的内容。
智能体名称: {application_name}
功能描述: {detail}

View File

@ -131,12 +131,10 @@ const promptTemplates = {
INIT_TEMPLATE: `
请根据用户描述生成一个完整的AI角色人设模板:
应用名称{application_name}
应用描述{detail}
用户需求{userInput}
重要说明
1. 角色设定必须服务于"{application_name}"应用的核心功能
1. 角色设定必须服务于"{userInput}"内容设定应用的核心功能
2. 允许用户对角色设定的具体内容进行调整和优化
3. 如果用户要求修改某个技能或部分在保持应用主题的前提下进行相应调整