浏览代码

Inner prompt parameter setting. (#4806)

### What problem does this PR solve?

#4764

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
tags/v0.17.0
Kevin Hu 8 个月前
父节点
当前提交
f64ae9dc33
没有帐户链接到提交者的电子邮件

+ 39
- 26
agent/component/generate.py 查看文件

component_name = "Generate" component_name = "Generate"


def get_dependent_components(self): def get_dependent_components(self):
cpnts = set([para["component_id"].split("@")[0] for para in self._param.parameters \
if para.get("component_id") \
and para["component_id"].lower().find("answer") < 0 \
and para["component_id"].lower().find("begin") < 0])
inputs = self.get_input_elements()
cpnts = set([i["key"] for i in inputs[1:] if i["key"].lower().find("answer") < 0 and i["key"].lower().find("begin") < 0])
return list(cpnts) return list(cpnts)


def set_cite(self, retrieval_res, answer): def set_cite(self, retrieval_res, answer):
return res return res


def get_input_elements(self): def get_input_elements(self):
if self._param.parameters:
return [{"key": "user", "name": "Input your question here:"}, *self._param.parameters]

return [{"key": "user", "name": "Input your question here:"}]
key_set = set([])
res = [{"key": "user", "name": "Input your question here:"}]
for r in re.finditer(r"\{([a-z]+[:@][a-z0-9_-]+)\}", self._param.prompt, flags=re.IGNORECASE):
cpn_id = r.group(1)
if cpn_id in key_set:
continue
if cpn_id.lower().find("begin@") == 0:
cpn_id, key = cpn_id.split("@")
for p in self._canvas.get_component(cpn_id)["obj"]._param.query:
if p["key"] != key:
continue
res.append({"key": r.group(1), "name": p["name"]})
key_set.add(r.group(1))
continue
cpn_nm = self._canvas.get_compnent_name(cpn_id)
if not cpn_nm:
continue
res.append({"key": cpn_id, "name": cpn_nm})
key_set.add(cpn_id)
return res


def _run(self, history, **kwargs): def _run(self, history, **kwargs):
chat_mdl = LLMBundle(self._canvas.get_tenant_id(), LLMType.CHAT, self._param.llm_id) chat_mdl = LLMBundle(self._canvas.get_tenant_id(), LLMType.CHAT, self._param.llm_id)


retrieval_res = [] retrieval_res = []
self._param.inputs = [] self._param.inputs = []
for para in self._param.parameters:
if not para.get("component_id"):
continue
component_id = para["component_id"].split("@")[0]
if para["component_id"].lower().find("@") >= 0:
cpn_id, key = para["component_id"].split("@")
for para in self.get_input_elements()[1:]:
if para["key"].lower().find("begin@") == 0:
cpn_id, key = para["key"].split("@")
for p in self._canvas.get_component(cpn_id)["obj"]._param.query: for p in self._canvas.get_component(cpn_id)["obj"]._param.query:
if p["key"] == key: if p["key"] == key:
kwargs[para["key"]] = p.get("value", "") kwargs[para["key"]] = p.get("value", "")
self._param.inputs.append( self._param.inputs.append(
{"component_id": para["component_id"], "content": kwargs[para["key"]]})
{"component_id": para["key"], "content": kwargs[para["key"]]})
break break
else: else:
assert False, f"Can't find parameter '{key}' for {cpn_id}" assert False, f"Can't find parameter '{key}' for {cpn_id}"
continue continue


component_id = para["key"]
cpn = self._canvas.get_component(component_id)["obj"] cpn = self._canvas.get_component(component_id)["obj"]
if cpn.component_name.lower() == "answer": if cpn.component_name.lower() == "answer":
hist = self._canvas.get_history(1) hist = self._canvas.get_history(1)
else: else:
if cpn.component_name.lower() == "retrieval": if cpn.component_name.lower() == "retrieval":
retrieval_res.append(out) retrieval_res.append(out)
kwargs[para["key"]] = " - "+"\n - ".join([o if isinstance(o, str) else str(o) for o in out["content"]])
self._param.inputs.append({"component_id": para["component_id"], "content": kwargs[para["key"]]})
kwargs[para["key"]] = " - " + "\n - ".join([o if isinstance(o, str) else str(o) for o in out["content"]])
self._param.inputs.append({"component_id": para["key"], "content": kwargs[para["key"]]})


if retrieval_res: if retrieval_res:
retrieval_res = pd.concat(retrieval_res, ignore_index=True) retrieval_res = pd.concat(retrieval_res, ignore_index=True)
return partial(self.stream_output, chat_mdl, prompt, retrieval_res) return partial(self.stream_output, chat_mdl, prompt, retrieval_res)


if "empty_response" in retrieval_res.columns and not "".join(retrieval_res["content"]): if "empty_response" in retrieval_res.columns and not "".join(retrieval_res["content"]):
res = {"content": "\n- ".join(retrieval_res["empty_response"]) if "\n- ".join(
retrieval_res["empty_response"]) else "Nothing found in knowledgebase!", "reference": []}
empty_res = "\n- ".join([str(t) for t in retrieval_res["empty_response"] if str(t)])
res = {"content": empty_res if empty_res else "Nothing found in knowledgebase!", "reference": []}
return pd.DataFrame([res]) return pd.DataFrame([res])


msg = self._canvas.get_history(self._param.message_history_window_size) msg = self._canvas.get_history(self._param.message_history_window_size)
if len(msg) < 1: if len(msg) < 1:
msg.append({"role": "user", "content": ""})
msg.append({"role": "user", "content": "Output: "})
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97)) _, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
if len(msg) < 2: if len(msg) < 2:
msg.append({"role": "user", "content": ""})
msg.append({"role": "user", "content": "Output: "})
ans = chat_mdl.chat(msg[0]["content"], msg[1:], self._param.gen_conf()) ans = chat_mdl.chat(msg[0]["content"], msg[1:], self._param.gen_conf())


if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns: if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns:
def stream_output(self, chat_mdl, prompt, retrieval_res): def stream_output(self, chat_mdl, prompt, retrieval_res):
res = None res = None
if "empty_response" in retrieval_res.columns and not "".join(retrieval_res["content"]): if "empty_response" in retrieval_res.columns and not "".join(retrieval_res["content"]):
res = {"content": "\n- ".join(retrieval_res["empty_response"]) if "\n- ".join(
retrieval_res["empty_response"]) else "Nothing found in knowledgebase!", "reference": []}
empty_res = "\n- ".join([str(t) for t in retrieval_res["empty_response"] if str(t)])
res = {"content": empty_res if empty_res else "Nothing found in knowledgebase!", "reference": []}
yield res yield res
self.set_output(res) self.set_output(res)
return return


msg = self._canvas.get_history(self._param.message_history_window_size) msg = self._canvas.get_history(self._param.message_history_window_size)
if len(msg) < 1: if len(msg) < 1:
msg.append({"role": "user", "content": ""})
msg.append({"role": "user", "content": "Output: "})
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97)) _, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
if len(msg) < 2: if len(msg) < 2:
msg.append({"role": "user", "content": ""})
msg.append({"role": "user", "content": "Output: "})
answer = "" answer = ""
for ans in chat_mdl.chat_streamly(msg[0]["content"], msg[1:], self._param.gen_conf()): for ans in chat_mdl.chat_streamly(msg[0]["content"], msg[1:], self._param.gen_conf()):
res = {"content": ans, "reference": []} res = {"content": ans, "reference": []}
for n, v in kwargs.items(): for n, v in kwargs.items():
prompt = re.sub(r"\{%s\}" % re.escape(n), str(v).replace("\\", " "), prompt) prompt = re.sub(r"\{%s\}" % re.escape(n), str(v).replace("\\", " "), prompt)


ans = chat_mdl.chat(prompt, [{"role": "user", "content": kwargs.get("user", "")}], self._param.gen_conf())
u = kwargs.get("user")
ans = chat_mdl.chat(prompt, [{"role": "user", "content": u if u else "Output: "}], self._param.gen_conf())
return pd.DataFrame([ans]) return pd.DataFrame([ans])

+ 29
- 16
agent/component/template.py 查看文件

component_name = "Template" component_name = "Template"


def get_dependent_components(self): def get_dependent_components(self):
cpnts = set(
[
para["component_id"].split("@")[0]
for para in self._param.parameters
if para.get("component_id")
and para["component_id"].lower().find("answer") < 0
and para["component_id"].lower().find("begin") < 0
]
)
inputs = self.get_input_elements()
cpnts = set([i["key"] for i in inputs if i["key"].lower().find("answer") < 0 and i["key"].lower().find("begin") < 0])
return list(cpnts) return list(cpnts)


def get_input_elements(self):
key_set = set([])
res = []
for r in re.finditer(r"\{([a-z]+[:@][a-z0-9_-]+)\}", self._param.content, flags=re.IGNORECASE):
cpn_id = r.group(1)
if cpn_id in key_set:
continue
if cpn_id.lower().find("begin@") == 0:
cpn_id, key = cpn_id.split("@")
for p in self._canvas.get_component(cpn_id)["obj"]._param.query:
if p["key"] != key:
continue
res.append({"key": r.group(1), "name": p["name"]})
key_set.add(r.group(1))
continue
cpn_nm = self._canvas.get_compnent_name(cpn_id)
if not cpn_nm:
continue
res.append({"key": cpn_id, "name": cpn_nm})
key_set.add(cpn_id)
return res

def _run(self, history, **kwargs): def _run(self, history, **kwargs):
content = self._param.content content = self._param.content


self._param.inputs = [] self._param.inputs = []
for para in self._param.parameters:
if not para.get("component_id"):
continue
component_id = para["component_id"].split("@")[0]
if para["component_id"].lower().find("@") >= 0:
cpn_id, key = para["component_id"].split("@")
for para in self.get_input_elements():
if para["key"].lower().find("begin@") == 0:
cpn_id, key = para["key"].split("@")
for p in self._canvas.get_component(cpn_id)["obj"]._param.query: for p in self._canvas.get_component(cpn_id)["obj"]._param.query:
if p["key"] == key: if p["key"] == key:
value = p.get("value", "") value = p.get("value", "")
assert False, f"Can't find parameter '{key}' for {cpn_id}" assert False, f"Can't find parameter '{key}' for {cpn_id}"
continue continue


component_id = para["key"]
cpn = self._canvas.get_component(component_id)["obj"] cpn = self._canvas.get_component(component_id)["obj"]
if cpn.component_name.lower() == "answer": if cpn.component_name.lower() == "answer":
hist = self._canvas.get_history(1) hist = self._canvas.get_history(1)


def make_kwargs(self, para, kwargs, value): def make_kwargs(self, para, kwargs, value):
self._param.inputs.append( self._param.inputs.append(
{"component_id": para["component_id"], "content": value}
{"component_id": para["key"], "content": value}
) )
try: try:
value = json.loads(value) value = json.loads(value)

+ 854
- 852
agent/templates/DB Assistant.json
文件差异内容过多而无法显示
查看文件


+ 1591
- 1353
agent/templates/HR_callout_zh.json
文件差异内容过多而无法显示
查看文件


+ 945
- 800
agent/templates/customer_service.json
文件差异内容过多而无法显示
查看文件


+ 2162
- 1769
agent/templates/general_chat_bot.json
文件差异内容过多而无法显示
查看文件


+ 462
- 530
agent/templates/interpreter.json
文件差异内容过多而无法显示
查看文件


+ 623
- 551
agent/templates/investment_advisor.json
文件差异内容过多而无法显示
查看文件


+ 342
- 231
agent/templates/medical_consultation.json 查看文件

"dsl": { "dsl": {
"answer": [], "answer": [],
"components": { "components": {
"begin": {
"obj": {
"component_name": "Begin",
"params": {}
},
"Answer:FlatRavensPush": {
"downstream": [ "downstream": [
"Answer:FlatRavensPush"
"Generate:QuietMelonsHear",
"Generate:FortyBaboonsRule"
], ],
"upstream": []
},
"PubMed:TwentyFansShake": {
"obj": { "obj": {
"component_name": "PubMed",
"component_name": "Answer",
"inputs": [],
"output": null,
"params": { "params": {
"email": "928018077@qq.com",
"top_n": 10
"debug_inputs": [],
"inputs": [],
"message_history_window_size": 22,
"output": null,
"output_var_name": "output",
"post_answers": [],
"query": []
} }
}, },
"downstream": [
"Generate:SolidCrewsStare"
],
"upstream": [ "upstream": [
"Generate:FortyBaboonsRule"
"begin",
"Generate:BrightCitiesSink"
] ]
}, },
"Answer:FlatRavensPush": {
"obj": {
"component_name": "Answer",
"params": {}
},
"Generate:BrightCitiesSink": {
"downstream": [ "downstream": [
"Generate:QuietMelonsHear",
"Generate:FortyBaboonsRule"
"Answer:FlatRavensPush"
], ],
"upstream": [
"begin",
"Generate:SolidCrewsStare"
]
},
"Generate:QuietMelonsHear": {
"obj": { "obj": {
"component_name": "Generate", "component_name": "Generate",
"inputs": [],
"output": null,
"params": { "params": {
"cite": true, "cite": true,
"debug_inputs": [],
"frequency_penalty": 0.7, "frequency_penalty": 0.7,
"inputs": [],
"llm_id": "deepseek-chat@DeepSeek", "llm_id": "deepseek-chat@DeepSeek",
"max_tokens": 256,
"max_tokens": 0,
"message_history_window_size": 12, "message_history_window_size": 12,
"output": null,
"output_var_name": "output",
"parameters": [], "parameters": [],
"presence_penalty": 0.4, "presence_penalty": 0.4,
"prompt": "Role: You are a professional medical consulting translation assistant\n\nTask: Translate user questions into Chinese, ensuring accuracy of medical terminology and appropriateness of context.\n\nRequirements:\n- Accurately translate medical terminology to convey the integrity and emotional color of the original message.\n- For unclear or uncertain medical terminology, the original text may be retained to ensure accuracy.\n- Respect the privacy and sensitivity of medical consultations and ensure that sensitive information is not disclosed during the translation process.\n- If the user's question is in Chinese, there is no need to translate, just output the user's question directly\n\nExample:\nOriginal (English): Doctor, I have been suffering from chest pain and shortness of breath for the past few days.\nTranslation (Chinese): 医生,我这几天一直胸痛和气短。\n\nNote:\nOnly the translated content needs to be output, no other irrelevant content!",
"prompt": "Role: You are a professional medical consulting assistant\n\nTasks: Answer questions posed by users. Answer based on content provided by the knowledge base, PubMed\n\nRequirement:\n- Answers may refer to the content provided (Knowledge Base, PubMed).\n- If the provided PubMed content is referenced, a link to the corresponding URL should be given.\n-Answers should be professional and accurate; no information should be fabricated that is not relevant to the user's question.\n\nProvided knowledge base content\n{Retrieval:BeigeBagsDress}\n\nPubMed content provided\n\n{PubMed:TwentyFansShake}",
"query": [],
"temperature": 0.1, "temperature": 0.1,
"top_p": 0.3 "top_p": 0.3
} }
}, },
"downstream": [
"Retrieval:BeigeBagsDress"
],
"upstream": [ "upstream": [
"Answer:FlatRavensPush"
"Retrieval:BeigeBagsDress",
"PubMed:TwentyFansShake"
] ]
}, },
"Generate:FortyBaboonsRule": { "Generate:FortyBaboonsRule": {
"downstream": [
"PubMed:TwentyFansShake"
],
"obj": { "obj": {
"component_name": "Generate", "component_name": "Generate",
"inputs": [],
"output": null,
"params": { "params": {
"cite": true,
"cite": false,
"debug_inputs": [],
"frequency_penalty": 0.7, "frequency_penalty": 0.7,
"inputs": [],
"llm_id": "deepseek-chat@DeepSeek", "llm_id": "deepseek-chat@DeepSeek",
"max_tokens": 256, "max_tokens": 256,
"message_history_window_size": 12,
"message_history_window_size": 1,
"output": null,
"output_var_name": "output",
"parameters": [], "parameters": [],
"presence_penalty": 0.4, "presence_penalty": 0.4,
"prompt": "Role: You are a professional Chinese-English medical question translation assistant\n\nTask: Accurately translate users' Chinese medical question content into English, ensuring accuracy of terminology and clarity of expression\n\nRequirements:\n- In-depth understanding of the terminology and disease descriptions in Chinese medical inquiries to ensure correct medical vocabulary is used in the English translation.\n- Maintain the semantic integrity and accuracy of the original text to avoid omitting important information or introducing errors.\n- Pay attention to the differences in expression habits between Chinese and English, and make appropriate adjustments to make the English translation more natural and fluent.\n- Respect the patient's privacy and the principle of medical confidentiality, and do not disclose any sensitive information during the translation process.\n\nExample:\nOriginal sentence: 我最近总是感觉胸闷,有时还会有心悸的感觉。\nTranslated: I've been feeling chest tightness recently, and sometimes I experience palpitations.\n\nNote:\nOnly the translated content should be given, do not output other irrelevant content!", "prompt": "Role: You are a professional Chinese-English medical question translation assistant\n\nTask: Accurately translate users' Chinese medical question content into English, ensuring accuracy of terminology and clarity of expression\n\nRequirements:\n- In-depth understanding of the terminology and disease descriptions in Chinese medical inquiries to ensure correct medical vocabulary is used in the English translation.\n- Maintain the semantic integrity and accuracy of the original text to avoid omitting important information or introducing errors.\n- Pay attention to the differences in expression habits between Chinese and English, and make appropriate adjustments to make the English translation more natural and fluent.\n- Respect the patient's privacy and the principle of medical confidentiality, and do not disclose any sensitive information during the translation process.\n\nExample:\nOriginal sentence: 我最近总是感觉胸闷,有时还会有心悸的感觉。\nTranslated: I've been feeling chest tightness recently, and sometimes I experience palpitations.\n\nNote:\nOnly the translated content should be given, do not output other irrelevant content!",
"query": [],
"temperature": 0.1, "temperature": 0.1,
"top_p": 0.3 "top_p": 0.3
} }
}, },
"downstream": [
"PubMed:TwentyFansShake"
],
"upstream": [ "upstream": [
"Answer:FlatRavensPush" "Answer:FlatRavensPush"
] ]
}, },
"Generate:SolidCrewsStare": {
"Generate:QuietMelonsHear": {
"downstream": [
"Retrieval:BeigeBagsDress"
],
"obj": { "obj": {
"component_name": "Generate", "component_name": "Generate",
"inputs": [],
"output": null,
"params": { "params": {
"cite": true, "cite": true,
"debug_inputs": [],
"frequency_penalty": 0.7, "frequency_penalty": 0.7,
"inputs": [],
"llm_id": "deepseek-chat@DeepSeek", "llm_id": "deepseek-chat@DeepSeek",
"max_tokens": 256, "max_tokens": 256,
"message_history_window_size": 12, "message_history_window_size": 12,
"parameters": [
{
"component_id": "PubMed:TwentyFansShake",
"id": "9fe5f82e-7be5-45d2-bc6c-1f9ba7e14b34",
"key": "pm_input"
},
{
"component_id": "Retrieval:BeigeBagsDress",
"id": "d2e7b0e2-e222-4776-988c-db239581a083",
"key": "kb_input"
}
],
"output": null,
"output_var_name": "output",
"parameters": [],
"presence_penalty": 0.4, "presence_penalty": 0.4,
"prompt": "Role: You are a professional medical consulting assistant\n\nTasks: Answer questions posed by users. Answer based on content provided by the knowledge base, PubMed\n\nRequirement:\n- Answers may refer to the content provided (Knowledge Base, PubMed).\n- If the provided PubMed content is referenced, a link to the corresponding URL should be given.\n-Answers should be professional and accurate; no information should be fabricated that is not relevant to the user's question.\n\nProvided knowledge base content\n{kb_input}\n\nPubMed content provided\n{pm_input}",
"prompt": "Role: You are a professional medical consulting translation assistant\n\nTask: Translate user questions into Chinese, ensuring accuracy of medical terminology and appropriateness of context.\n\nRequirements:\n- Accurately translate medical terminology to convey the integrity and emotional color of the original message.\n- For unclear or uncertain medical terminology, the original text may be retained to ensure accuracy.\n- Respect the privacy and sensitivity of medical consultations and ensure that sensitive information is not disclosed during the translation process.\n- If the user's question is in Chinese, there is no need to translate, just output the user's question directly\n\nExample:\nOriginal (English): Doctor, I have been suffering from chest pain and shortness of breath for the past few days.\nTranslation (Chinese): 医生,我这几天一直胸痛和气短。\n\nNote:\nOnly the translated content needs to be output, no other irrelevant content!",
"query": [],
"temperature": 0.1, "temperature": 0.1,
"top_p": 0.3 "top_p": 0.3
} }
}, },
"downstream": [
"upstream": [
"Answer:FlatRavensPush" "Answer:FlatRavensPush"
]
},
"PubMed:TwentyFansShake": {
"downstream": [
"Generate:BrightCitiesSink"
], ],
"obj": {
"component_name": "PubMed",
"inputs": [],
"output": null,
"params": {
"debug_inputs": [],
"email": "928018077@qq.com",
"inputs": [],
"message_history_window_size": 22,
"output": null,
"output_var_name": "output",
"query": [
{
"component_id": "Generate:FortyBaboonsRule",
"type": "reference"
}
],
"top_n": 10
}
},
"upstream": [ "upstream": [
"PubMed:TwentyFansShake",
"Retrieval:BeigeBagsDress"
"Generate:FortyBaboonsRule"
] ]
}, },
"Retrieval:BeigeBagsDress": { "Retrieval:BeigeBagsDress": {
"downstream": [
"Generate:BrightCitiesSink"
],
"obj": { "obj": {
"component_name": "Retrieval", "component_name": "Retrieval",
"inputs": [],
"output": null,
"params": { "params": {
"debug_inputs": [],
"empty_response": "",
"inputs": [],
"kb_ids": [], "kb_ids": [],
"keywords_similarity_weight": 0.3, "keywords_similarity_weight": 0.3,
"message_history_window_size": 22,
"output": null,
"output_var_name": "output",
"query": [
{
"component_id": "Generate:QuietMelonsHear",
"type": "reference"
}
],
"rerank_id": "",
"similarity_threshold": 0.2, "similarity_threshold": 0.2,
"top_k": 1024,
"top_n": 8 "top_n": 8
} }
}, },
"downstream": [
"Generate:SolidCrewsStare"
],
"upstream": [ "upstream": [
"Generate:QuietMelonsHear" "Generate:QuietMelonsHear"
] ]
},
"begin": {
"downstream": [
"Answer:FlatRavensPush"
],
"obj": {
"component_name": "Begin",
"inputs": [],
"output": null,
"params": {
"debug_inputs": [],
"inputs": [],
"message_history_window_size": 22,
"output": null,
"output_var_name": "output",
"prologue": "Hi! I'm your smart assistant. What can I do for you?",
"query": []
}
},
"upstream": []
} }
}, },
"embed_id": "",
"graph": { "graph": {
"edges": [
{
"id": "reactflow__edge-begin-Answer:FlatRavensPushc",
"markerEnd": "logo",
"source": "begin",
"sourceHandle": null,
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Answer:FlatRavensPush",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Answer:FlatRavensPushb-Generate:QuietMelonsHearc",
"markerEnd": "logo",
"source": "Answer:FlatRavensPush",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Generate:QuietMelonsHear",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Answer:FlatRavensPushb-Generate:FortyBaboonsRulec",
"markerEnd": "logo",
"source": "Answer:FlatRavensPush",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Generate:FortyBaboonsRule",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Generate:FortyBaboonsRuleb-PubMed:TwentyFansShakec",
"markerEnd": "logo",
"source": "Generate:FortyBaboonsRule",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "PubMed:TwentyFansShake",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Generate:QuietMelonsHearb-Retrieval:BeigeBagsDressc",
"markerEnd": "logo",
"source": "Generate:QuietMelonsHear",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Retrieval:BeigeBagsDress",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "xy-edge__Retrieval:BeigeBagsDressb-Generate:BrightCitiesSinkb",
"markerEnd": "logo",
"source": "Retrieval:BeigeBagsDress",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Generate:BrightCitiesSink",
"targetHandle": "b",
"type": "buttonEdge",
"zIndex": 1001
},
{
"id": "xy-edge__PubMed:TwentyFansShakeb-Generate:BrightCitiesSinkb",
"markerEnd": "logo",
"source": "PubMed:TwentyFansShake",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Generate:BrightCitiesSink",
"targetHandle": "b",
"type": "buttonEdge",
"zIndex": 1001
},
{
"id": "xy-edge__Generate:BrightCitiesSinkc-Answer:FlatRavensPushc",
"markerEnd": "logo",
"source": "Generate:BrightCitiesSink",
"sourceHandle": "c",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Answer:FlatRavensPush",
"targetHandle": "c",
"type": "buttonEdge",
"zIndex": 1001
}
],
"nodes": [ "nodes": [
{ {
"data": { "data": {
"dragging": false, "dragging": false,
"height": 44, "height": 44,
"id": "begin", "id": "begin",
"measured": {
"height": 44,
"width": 100
},
"position": { "position": {
"x": -599.8361708291377, "x": -599.8361708291377,
"y": 161.91688790133628 "y": 161.91688790133628
"data": { "data": {
"form": { "form": {
"email": "928018077@qq.com", "email": "928018077@qq.com",
"query": [
{
"component_id": "Generate:FortyBaboonsRule",
"type": "reference"
}
],
"top_n": 10 "top_n": 10
}, },
"label": "PubMed", "label": "PubMed",
"dragging": false, "dragging": false,
"height": 44, "height": 44,
"id": "PubMed:TwentyFansShake", "id": "PubMed:TwentyFansShake",
"measured": {
"height": 44,
"width": 200
},
"position": { "position": {
"x": 389.7229173847695,
"y": 276.4372267765921
"x": 388.4151716305788,
"y": 272.51398951401995
}, },
"positionAbsolute": { "positionAbsolute": {
"x": 389.7229173847695, "x": 389.7229173847695,
"dragging": false, "dragging": false,
"height": 44, "height": 44,
"id": "Answer:FlatRavensPush", "id": "Answer:FlatRavensPush",
"measured": {
"height": 44,
"width": 200
},
"position": { "position": {
"x": -370.881803561134,
"y": 161.41373998842477
"x": -277.4280835723395,
"y": 162.89713236919926
}, },
"positionAbsolute": { "positionAbsolute": {
"x": -370.881803561134, "x": -370.881803561134,
"dragging": false, "dragging": false,
"height": 86, "height": 86,
"id": "Generate:QuietMelonsHear", "id": "Generate:QuietMelonsHear",
"measured": {
"height": 86,
"width": 200
},
"position": { "position": {
"x": -2.756518132081453, "x": -2.756518132081453,
"y": 38.86485966020132 "y": 38.86485966020132
{ {
"data": { "data": {
"form": { "form": {
"cite": true,
"cite": false,
"frequencyPenaltyEnabled": true, "frequencyPenaltyEnabled": true,
"frequency_penalty": 0.7, "frequency_penalty": 0.7,
"llm_id": "deepseek-chat@DeepSeek", "llm_id": "deepseek-chat@DeepSeek",
"maxTokensEnabled": true, "maxTokensEnabled": true,
"max_tokens": 256, "max_tokens": 256,
"message_history_window_size": 12,
"message_history_window_size": 1,
"parameter": "Precise", "parameter": "Precise",
"parameters": [], "parameters": [],
"presencePenaltyEnabled": true, "presencePenaltyEnabled": true,
"dragging": false, "dragging": false,
"height": 86, "height": 86,
"id": "Generate:FortyBaboonsRule", "id": "Generate:FortyBaboonsRule",
"measured": {
"height": 86,
"width": 200
},
"position": { "position": {
"x": -3.825864707727135, "x": -3.825864707727135,
"y": 253.2285157283701 "y": 253.2285157283701
{ {
"data": { "data": {
"form": { "form": {
"cite": true,
"frequencyPenaltyEnabled": true,
"frequency_penalty": 0.7,
"llm_id": "deepseek-chat@DeepSeek",
"maxTokensEnabled": true,
"max_tokens": 256,
"message_history_window_size": 12,
"parameter": "Precise",
"parameters": [
{
"component_id": "PubMed:TwentyFansShake",
"id": "9fe5f82e-7be5-45d2-bc6c-1f9ba7e14b34",
"key": "pm_input"
},
"kb_ids": [],
"keywords_similarity_weight": 0.3,
"query": [
{ {
"component_id": "Retrieval:BeigeBagsDress",
"id": "d2e7b0e2-e222-4776-988c-db239581a083",
"key": "kb_input"
"component_id": "Generate:QuietMelonsHear",
"type": "reference"
} }
], ],
"presencePenaltyEnabled": true,
"presence_penalty": 0.4,
"prompt": "Role: You are a professional medical consulting assistant\n\nTasks: Answer questions posed by users. Answer based on content provided by the knowledge base, PubMed\n\nRequirement:\n- Answers may refer to the content provided (Knowledge Base, PubMed).\n- If the provided PubMed content is referenced, a link to the corresponding URL should be given.\n-Answers should be professional and accurate; no information should be fabricated that is not relevant to the user's question.\n\nProvided knowledge base content\n{kb_input}\n\nPubMed content provided\n{pm_input}",
"temperature": 0.1,
"temperatureEnabled": true,
"topPEnabled": true,
"top_p": 0.3
},
"label": "Generate",
"name": "LLM"
},
"dragging": false,
"height": 172,
"id": "Generate:SolidCrewsStare",
"position": {
"x": 427.0382682049008,
"y": -221.26975391424511
},
"positionAbsolute": {
"x": 427.0382682049008,
"y": -221.26975391424511
},
"selected": true,
"sourcePosition": "right",
"targetPosition": "left",
"type": "generateNode",
"width": 200
},
{
"data": {
"form": {
"kb_ids": [],
"keywords_similarity_weight": 0.3,
"similarity_threshold": 0.2, "similarity_threshold": 0.2,
"top_n": 8 "top_n": 8
}, },
"dragging": false, "dragging": false,
"height": 44, "height": 44,
"id": "Retrieval:BeigeBagsDress", "id": "Retrieval:BeigeBagsDress",
"measured": {
"height": 44,
"width": 200
},
"position": { "position": {
"x": 382.25527986090765,
"y": 35.38705653631584
"x": 316.9462115194757,
"y": 57.81358887451738
}, },
"positionAbsolute": { "positionAbsolute": {
"x": 382.25527986090765, "x": 382.25527986090765,
"dragging": false, "dragging": false,
"height": 162, "height": 162,
"id": "Note:RedZebrasEnjoy", "id": "Note:RedZebrasEnjoy",
"measured": {
"height": 162,
"width": 200
},
"position": { "position": {
"x": -374.13983303471906,
"y": 219.54112331790157
"x": -274.75115571622416,
"y": 233.92632661399952
}, },
"positionAbsolute": { "positionAbsolute": {
"x": -374.13983303471906, "x": -374.13983303471906,
"dragging": false, "dragging": false,
"height": 128, "height": 128,
"id": "Note:DarkIconsClap", "id": "Note:DarkIconsClap",
"measured": {
"height": 128,
"width": 227
},
"position": { "position": {
"x": -0.453362859534991,
"y": 357.3687792184929
"x": -2.0308204014422273,
"y": 379.60045703973515
}, },
"positionAbsolute": { "positionAbsolute": {
"x": -0.453362859534991, "x": -0.453362859534991,
}, },
"targetPosition": "left", "targetPosition": "left",
"type": "noteNode", "type": "noteNode",
"width": 204
"width": 227
}, },
{ {
"data": { "data": {
"dragging": false, "dragging": false,
"height": 128, "height": 128,
"id": "Note:SmallRiversTap", "id": "Note:SmallRiversTap",
"measured": {
"height": 128,
"width": 220
},
"position": { "position": {
"x": -5.453362859535048,
"y": -105.63122078150693
"x": -2.9326060127226583,
"y": -99.3117253460485
}, },
"positionAbsolute": { "positionAbsolute": {
"x": -5.453362859535048, "x": -5.453362859535048,
}, },
"targetPosition": "left", "targetPosition": "left",
"type": "noteNode", "type": "noteNode",
"width": 196
"width": 220
}, },
{ {
"data": { "data": {
"dragging": false, "dragging": false,
"height": 220, "height": 220,
"id": "Note:MightyDeerShout", "id": "Note:MightyDeerShout",
"measured": {
"height": 220,
"width": 287
},
"position": { "position": {
"x": 718.5466371404648, "x": 718.5466371404648,
"y": 275.36877921849293 "y": 275.36877921849293
"dragging": false, "dragging": false,
"height": 128, "height": 128,
"id": "Note:VioletSuitsFlash", "id": "Note:VioletSuitsFlash",
"measured": {
"height": 128,
"width": 387
},
"position": { "position": {
"x": 776.4332169584197, "x": 776.4332169584197,
"y": 32.89802610798361 "y": 32.89802610798361
}, },
"dragHandle": ".note-drag-handle", "dragHandle": ".note-drag-handle",
"dragging": false, "dragging": false,
"height": 128,
"height": 140,
"id": "Note:BeigeCoinsBuild", "id": "Note:BeigeCoinsBuild",
"measured": {
"height": 140,
"width": 281
},
"position": { "position": {
"x": 756.9053449234701,
"y": -212.92342186138177
"x": 293.89948660403513,
"y": -238.31673896113236
}, },
"positionAbsolute": { "positionAbsolute": {
"x": 756.9053449234701, "x": 756.9053449234701,
"y": -212.92342186138177 "y": -212.92342186138177
}, },
"resizing": false,
"selected": false, "selected": false,
"sourcePosition": "right", "sourcePosition": "right",
"targetPosition": "left", "targetPosition": "left",
"type": "noteNode", "type": "noteNode",
"width": 269
}
],
"edges": [
{
"id": "reactflow__edge-begin-Answer:FlatRavensPushc",
"markerEnd": "logo",
"source": "begin",
"sourceHandle": null,
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Answer:FlatRavensPush",
"targetHandle": "c",
"type": "buttonEdge"
"width": 281
}, },
{ {
"id": "reactflow__edge-Answer:FlatRavensPushb-Generate:QuietMelonsHearc",
"markerEnd": "logo",
"source": "Answer:FlatRavensPush",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Generate:QuietMelonsHear",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Answer:FlatRavensPushb-Generate:FortyBaboonsRulec",
"markerEnd": "logo",
"source": "Answer:FlatRavensPush",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Generate:FortyBaboonsRule",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Generate:FortyBaboonsRuleb-PubMed:TwentyFansShakec",
"markerEnd": "logo",
"source": "Generate:FortyBaboonsRule",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "PubMed:TwentyFansShake",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-PubMed:TwentyFansShakeb-Generate:SolidCrewsStareb",
"markerEnd": "logo",
"source": "PubMed:TwentyFansShake",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
},
"target": "Generate:SolidCrewsStare",
"targetHandle": "b",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Retrieval:BeigeBagsDressb-Generate:SolidCrewsStareb",
"markerEnd": "logo",
"source": "Retrieval:BeigeBagsDress",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
"data": {
"form": {
"cite": true,
"frequencyPenaltyEnabled": true,
"frequency_penalty": 0.7,
"llm_id": "deepseek-chat@DeepSeek",
"maxTokensEnabled": false,
"max_tokens": 256,
"message_history_window_size": 12,
"parameter": "Precise",
"parameters": [],
"presencePenaltyEnabled": true,
"presence_penalty": 0.4,
"prompt": "Role: You are a professional medical consulting assistant\n\nTasks: Answer questions posed by users. Answer based on content provided by the knowledge base, PubMed\n\nRequirement:\n- Answers may refer to the content provided (Knowledge Base, PubMed).\n- If the provided PubMed content is referenced, a link to the corresponding URL should be given.\n-Answers should be professional and accurate; no information should be fabricated that is not relevant to the user's question.\n\nProvided knowledge base content\n{Retrieval:BeigeBagsDress}\n\nPubMed content provided\n\n{PubMed:TwentyFansShake}",
"temperature": 0.1,
"temperatureEnabled": true,
"topPEnabled": true,
"top_p": 0.3
},
"label": "Generate",
"name": "LLM"
}, },
"target": "Generate:SolidCrewsStare",
"targetHandle": "b",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Generate:QuietMelonsHearb-Retrieval:BeigeBagsDressc",
"markerEnd": "logo",
"source": "Generate:QuietMelonsHear",
"sourceHandle": "b",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
"dragging": false,
"id": "Generate:BrightCitiesSink",
"measured": {
"height": 106,
"width": 200
}, },
"target": "Retrieval:BeigeBagsDress",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"id": "reactflow__edge-Generate:SolidCrewsStarec-Answer:FlatRavensPushc",
"markerEnd": "logo",
"source": "Generate:SolidCrewsStare",
"sourceHandle": "c",
"style": {
"stroke": "rgb(202 197 245)",
"strokeWidth": 2
"position": {
"x": 300,
"y": -86.3689104694316
}, },
"target": "Answer:FlatRavensPush",
"targetHandle": "c",
"type": "buttonEdge"
"selected": false,
"sourcePosition": "right",
"targetPosition": "left",
"type": "generateNode"
} }
] ]
}, },

+ 610
- 724
agent/templates/research_report.json
文件差异内容过多而无法显示
查看文件


+ 1194
- 1395
agent/templates/seo_blog.json
文件差异内容过多而无法显示
查看文件


+ 604
- 537
agent/templates/text2sql.json
文件差异内容过多而无法显示
查看文件


+ 933
- 795
agent/templates/websearch_assistant.json
文件差异内容过多而无法显示
查看文件


正在加载...
取消
保存