diff --git a/agent/component/base.py b/agent/component/base.py index 1aa9629e59..63d5f0d84b 100644 --- a/agent/component/base.py +++ b/agent/component/base.py @@ -390,8 +390,8 @@ def __str__(self): "inputs": {} }}""".format(self.component_name, self._param, - json.dumps(json.loads(str(self._param))["output"], ensure_ascii=False), - json.dumps(json.loads(str(self._param))["inputs"], ensure_ascii=False) + json.dumps(json.loads(str(self._param)).get("output", {}), ensure_ascii=False), + json.dumps(json.loads(str(self._param)).get("inputs", []), ensure_ascii=False) ) def __init__(self, canvas, id, param: ComponentParamBase): diff --git a/agent/component/generate.py b/agent/component/generate.py index c6640c8898..14a65add10 100644 --- a/agent/component/generate.py +++ b/agent/component/generate.py @@ -145,7 +145,7 @@ def _run(self, history, **kwargs): else: retrieval_res = pd.DataFrame([]) for n, v in kwargs.items(): - prompt = re.sub(r"\{%s\}" % re.escape(n), str(v), prompt) + prompt = re.sub(r"\{%s\}" % re.escape(n), str(v).replace("\\", " "), prompt) if not self._param.inputs and prompt.find("{input}") >= 0: retrieval_res = self.get_input() diff --git a/agent/component/template.py b/agent/component/template.py index 06f84114e2..8964752941 100644 --- a/agent/component/template.py +++ b/agent/component/template.py @@ -79,7 +79,7 @@ def _run(self, history, **kwargs): self._param.inputs.append({"component_id": para["component_id"], "content": kwargs[para["key"]]}) for n, v in kwargs.items(): - content = re.sub(r"\{%s\}" % re.escape(n), str(v), content) + content = re.sub(r"\{%s\}" % re.escape(n), str(v).replace("\\", " "), content) return Template.be_output(content) diff --git a/agent/templates/interpreter.json b/agent/templates/interpreter.json index 773dc0fabe..7ea83d2dc4 100644 --- a/agent/templates/interpreter.json +++ b/agent/templates/interpreter.json @@ -1,7 +1,7 @@ { "id": 4, "title": "Interpreter", - "description": "A simple interpreter that translates user input into a target language. Try 'Hi there => Spanish' to see the translation!", + "description": "Translation Agent: Agentic translation using reflection workflow.\n\nThis is inspired by Andrew NG's project: https://github.com/andrewyng/translation-agent\n\n", "canvas_type": "chatbot", "dsl": { "answer": [], @@ -13,10 +13,6 @@ "params": { "inputs": [], "message_history_window_size": 22, - "output": { - "content": "# Putin Approves New Russian Nuclear Deterrence Policy, China Responds\n\nDuring a regular press conference on November 20th, a reporter asked about two significant events: Russian President Vladimir Putin's approval of the new basic policy on Russia's nuclear deterrence, and the subsequent missile attack by Ukrainian forces on the Bryansk region of Russia. The reporter asked for China's position on these developments.\n\nOn November 19th, President Putin signed a decree approving the updated policy for Russia's nuclear deterrence. The document states that Russia views nuclear weapons as a means of deterrence and that their use would be an extreme measure taken under compulsion. On the same day, the Bryansk region was targeted by six U.S.-made missiles launched by Ukrainian forces. According to a report from the Russian Defense Ministry, all six missiles were intercepted by Russia's air defense systems, with debris falling within a military area in Bryansk.\n\nIn response to these events, Chinese Foreign Ministry spokesperson Lin Jian stated that we have noted the relevant reports. In the current context, all parties should remain calm and restrained, engaging in dialogue and consultation to jointly promote de-escalation and reduce strategic risks.\n\nLin emphasized that China's position on the Ukraine issue has been consistent and clear. China hopes that all parties will work towards easing tensions and pursuing political resolution of the Ukraine crisis. China remains committed to playing a constructive role in this regard.", - "reference": [] - }, "output_var_name": "output", "post_answers": [], "query": [] @@ -35,31 +31,10 @@ "params": { "cite": false, "frequency_penalty": 0.7, - "inputs": [ - { - "component_id": "begin@lang", - "content": "English" - }, - { - "component_id": "begin@file", - "content": "https://www.sohu.com/a/828560323_162522?edtsign=70AF5B785A09DF20C126EABC2EC4FB4ABA309622&edtcode=2PBU%2BTiMwCHq%2FwmFSXvzFA%3D%3D&scm=10001.663_14-200000.0.10006.&_f=index_cpc_1_0&spm=smpc.channel_258.block4_314_Y6ubu8_1_fd.11.1732094805514oPmAsKj_1090\n\u666e\u4eac\u6279\u51c6\u65b0\u7248\u4fc4\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\uff0c\u5916\u4ea4\u90e8\u56de\u5e94_\u5e03\u826f\u65af_\u7f8e\u5236_\u4e2d\u65b9\n\u3010\u73af\u7403\u65f6\u62a5-\u73af\u7403\u7f51\u62a5\u9053 \u8bb0\u8005 \u767d\u4e91\u6021\u3011\u572811\u670820\u65e5\u5916\u4ea4\u90e8\u4f8b\u884c\u8bb0\u8005\u4f1a\u4e0a\uff0c\u6709\u8bb0\u8005\u63d0\u95ee\u79f0\uff0c\u4fc4\u7f57\u65af\u603b\u7edf\u666e\u4eac19\u65e5\u7b7e\u7f72\u603b\u7edf\u4ee4\uff0c\u6279\u51c6\u65b0\u7248\u4fc4\u7f57\u65af\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\u3002\u6587\u4ef6\u79f0\uff0c\u4fc4\u7f57\u65af\u89c6\u6838\u6b66\u5668\u4e3a\u4e00\u79cd\u5a01\u6151\u624b\u6bb5\uff0c\u4f7f\u7528\u6838\u6b66\u5668\u662f\u6781\u7aef\u60c5\u51b5\u4e0b\u88ab\u8feb\u91c7\u53d6\u7684\u63aa\u65bd\u3002\u540c\u65e5\uff0c\u4fc4\u5e03\u826f\u65af\u514b\u5dde\u906d\u5230\u4e4c\u519b6\u679a\u7f8e\u5236\u5bfc\u5f39\u88ad\u51fb\u3002\u4fc4\u56fd\u9632\u90e8\u7684\u901a\u62a5\u79f0\uff0c\u7ecf\u786e\u8ba4\uff0c\u4e4c\u65b9\u4f7f\u7528\u7684\u662f\u7f8e\u5236\u9646\u519b\u6218\u672f\u5bfc\u5f39\u7cfb\u7edf\uff0c6\u679a\u5bfc\u5f39\u5168\u90e8\u88ab\u4fc4\u519b\u9632\u7a7a\u7cfb\u7edf\u62e6\u622a\uff0c\u5bfc\u5f39\u6b8b\u7247\u843d\u5165\u5e03\u826f\u65af\u514b\u5dde\u4e00\u5904\u519b\u4e8b\u533a\u57df\u5185\u3002\u4e2d\u65b9\u5bf9\u8fd9\u4e24\u4ef6\u4e8b\u60c5\u6709\u4f55\u8bc4\u8bba\uff1f\n\n\u5bf9\u6b64\uff0c\u4e2d\u56fd\u5916\u4ea4\u90e8\u53d1\u8a00\u4eba\u6797\u5251\u8868\u793a\uff0c\u6211\u4eec\u6ce8\u610f\u5230\u4e86\u6709\u5173\u62a5\u9053\u3002\u5f53\u524d\u5f62\u52bf\u4e0b\uff0c\u5404\u65b9\u5e94\u5f53\u4fdd\u6301\u51b7\u9759\u514b\u5236\uff0c\u901a\u8fc7\u5bf9\u8bdd\u534f\u5546\u5171\u540c\u63a8\u52a8\u5c40\u52bf\u7f13\u548c\uff0c\u51cf\u5c11\u6218\u7565\u98ce\u9669\u3002\n\n\u6797\u5251\u5f3a\u8c03\uff0c\u5728\u4e4c\u514b\u5170\u95ee\u9898\u4e0a\uff0c\u4e2d\u65b9\u7684\u7acb\u573a\u662f\u4e00\u8d2f\u7684\u3001\u660e\u786e\u7684\u3002\u4e2d\u65b9\u5e0c\u671b\u5404\u65b9\u63a8\u52a8\u7f13\u548c\u5c40\u52bf\u3001\u81f4\u529b\u4e8e\u653f\u6cbb\u89e3\u51b3\u4e4c\u514b\u5170\u5371\u673a\u7684\u7acb\u573a\u6ca1\u6709\u6539\u53d8\uff0c\u5e76\u5c06\u7ee7\u7eed\u4e3a\u6b64\u53d1\u6325\u5efa\u8bbe\u6027\u4f5c\u7528\u3002 \u8fd4\u56de\u641c\u72d0\uff0c\u67e5\u770b\u66f4\u591a\n\n\u8d23\u4efb\u7f16\u8f91\uff1a \u6bb7\u745e\u6c11 UN949\n----\n" - }, - { - "component_id": "Generate:RichWordsDeny", - "content": " - # Putin Approves New Russian Nuclear Deterrence Policy, China Responds\n\nIn a recent routine press conference on November 20th, a reporter inquired about two significant events: Russian President Vladimir Putin's approval of the new basic policy on Russia's nuclear deterrence, and the subsequent missile attack by Ukrainian forces on the Bryansk region of Russia. The reporter sought China's stance on these developments.\n\nOn November 19th, President Putin signed a decree approving the updated policy for Russia's nuclear deterrence. The document states that Russia views nuclear weapons as a means of deterrence and that their use would be an extreme measure taken under compulsion. On the same day, the Bryansk region was targeted by six U.S.-made missiles launched by Ukrainian forces. According to a report from the Russian Defense Ministry, all six missiles were intercepted by Russia's air defense systems, with debris falling within a military area in Bryansk.\n\nIn response to these events, Chinese Foreign Ministry spokesperson Lin Jian stated that China has taken note of the relevant reports. In the current context, all parties should remain calm and restrained, engaging in dialogue and consultation to jointly promote de-escalation and reduce strategic risks.\n\nLin emphasized that China's position on the Ukraine issue has been consistent and clear. China hopes that all parties will work towards easing tensions and pursuing political resolution of the Ukraine crisis. China remains committed to playing a constructive role in this regard." - }, - { - "component_id": "Generate:SlimyFrogsArgue", - "content": " - 1. **Accuracy**: The translation incorrectly states \"Chinese Foreign Ministry spokesperson Lin Jian\" instead of \"Chinese Foreign Ministry spokesperson Lin Jian.\" The correct name is \"Lin Jian,\" not \"Lin Jian.\"\n\n2. **Fluency**: The phrase \"In a recent routine press conference on November 20th, a reporter inquired about two significant events\" can be more fluently translated as \"During a regular press conference on November 20th, a reporter asked about two significant events.\"\n\n3. **Fluency**: The sentence \"The reporter sought China's stance on these developments\" can be improved to read more naturally: \"The reporter asked for China's position on these developments.\"\n\n4. **Style**: The phrase \"China has taken note of the relevant reports\" could be more stylistically aligned with the source text by using: \"We have noted the relevant reports.\"\n\n5. **Terminology**: The term \"Bryansk region\" should be consistently used throughout the translation instead of switching between \"Bryansk region\" and \"Bryansk.\"" - } - ], + "inputs": [], "llm_id": "deepseek-chat@DeepSeek", "max_tokens": 0, "message_history_window_size": 12, - "output": { - "content": "# Putin Approves New Russian Nuclear Deterrence Policy, China Responds\n\nDuring a regular press conference on November 20th, a reporter asked about two significant events: Russian President Vladimir Putin's approval of the new basic policy on Russia's nuclear deterrence, and the subsequent missile attack by Ukrainian forces on the Bryansk region of Russia. The reporter asked for China's position on these developments.\n\nOn November 19th, President Putin signed a decree approving the updated policy for Russia's nuclear deterrence. The document states that Russia views nuclear weapons as a means of deterrence and that their use would be an extreme measure taken under compulsion. On the same day, the Bryansk region was targeted by six U.S.-made missiles launched by Ukrainian forces. According to a report from the Russian Defense Ministry, all six missiles were intercepted by Russia's air defense systems, with debris falling within a military area in Bryansk.\n\nIn response to these events, Chinese Foreign Ministry spokesperson Lin Jian stated that we have noted the relevant reports. In the current context, all parties should remain calm and restrained, engaging in dialogue and consultation to jointly promote de-escalation and reduce strategic risks.\n\nLin emphasized that China's position on the Ukraine issue has been consistent and clear. China hopes that all parties will work towards easing tensions and pursuing political resolution of the Ukraine crisis. China remains committed to playing a constructive role in this regard.", - "reference": [] - }, "output_var_name": "output", "parameters": [ { @@ -103,24 +78,10 @@ "params": { "cite": false, "frequency_penalty": 0.7, - "inputs": [ - { - "component_id": "begin@lang", - "content": "English" - }, - { - "component_id": "begin@file", - "content": "https://www.sohu.com/a/828560323_162522?edtsign=70AF5B785A09DF20C126EABC2EC4FB4ABA309622&edtcode=2PBU%2BTiMwCHq%2FwmFSXvzFA%3D%3D&scm=10001.663_14-200000.0.10006.&_f=index_cpc_1_0&spm=smpc.channel_258.block4_314_Y6ubu8_1_fd.11.1732094805514oPmAsKj_1090\n\u666e\u4eac\u6279\u51c6\u65b0\u7248\u4fc4\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\uff0c\u5916\u4ea4\u90e8\u56de\u5e94_\u5e03\u826f\u65af_\u7f8e\u5236_\u4e2d\u65b9\n\u3010\u73af\u7403\u65f6\u62a5-\u73af\u7403\u7f51\u62a5\u9053 \u8bb0\u8005 \u767d\u4e91\u6021\u3011\u572811\u670820\u65e5\u5916\u4ea4\u90e8\u4f8b\u884c\u8bb0\u8005\u4f1a\u4e0a\uff0c\u6709\u8bb0\u8005\u63d0\u95ee\u79f0\uff0c\u4fc4\u7f57\u65af\u603b\u7edf\u666e\u4eac19\u65e5\u7b7e\u7f72\u603b\u7edf\u4ee4\uff0c\u6279\u51c6\u65b0\u7248\u4fc4\u7f57\u65af\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\u3002\u6587\u4ef6\u79f0\uff0c\u4fc4\u7f57\u65af\u89c6\u6838\u6b66\u5668\u4e3a\u4e00\u79cd\u5a01\u6151\u624b\u6bb5\uff0c\u4f7f\u7528\u6838\u6b66\u5668\u662f\u6781\u7aef\u60c5\u51b5\u4e0b\u88ab\u8feb\u91c7\u53d6\u7684\u63aa\u65bd\u3002\u540c\u65e5\uff0c\u4fc4\u5e03\u826f\u65af\u514b\u5dde\u906d\u5230\u4e4c\u519b6\u679a\u7f8e\u5236\u5bfc\u5f39\u88ad\u51fb\u3002\u4fc4\u56fd\u9632\u90e8\u7684\u901a\u62a5\u79f0\uff0c\u7ecf\u786e\u8ba4\uff0c\u4e4c\u65b9\u4f7f\u7528\u7684\u662f\u7f8e\u5236\u9646\u519b\u6218\u672f\u5bfc\u5f39\u7cfb\u7edf\uff0c6\u679a\u5bfc\u5f39\u5168\u90e8\u88ab\u4fc4\u519b\u9632\u7a7a\u7cfb\u7edf\u62e6\u622a\uff0c\u5bfc\u5f39\u6b8b\u7247\u843d\u5165\u5e03\u826f\u65af\u514b\u5dde\u4e00\u5904\u519b\u4e8b\u533a\u57df\u5185\u3002\u4e2d\u65b9\u5bf9\u8fd9\u4e24\u4ef6\u4e8b\u60c5\u6709\u4f55\u8bc4\u8bba\uff1f\n\n\u5bf9\u6b64\uff0c\u4e2d\u56fd\u5916\u4ea4\u90e8\u53d1\u8a00\u4eba\u6797\u5251\u8868\u793a\uff0c\u6211\u4eec\u6ce8\u610f\u5230\u4e86\u6709\u5173\u62a5\u9053\u3002\u5f53\u524d\u5f62\u52bf\u4e0b\uff0c\u5404\u65b9\u5e94\u5f53\u4fdd\u6301\u51b7\u9759\u514b\u5236\uff0c\u901a\u8fc7\u5bf9\u8bdd\u534f\u5546\u5171\u540c\u63a8\u52a8\u5c40\u52bf\u7f13\u548c\uff0c\u51cf\u5c11\u6218\u7565\u98ce\u9669\u3002\n\n\u6797\u5251\u5f3a\u8c03\uff0c\u5728\u4e4c\u514b\u5170\u95ee\u9898\u4e0a\uff0c\u4e2d\u65b9\u7684\u7acb\u573a\u662f\u4e00\u8d2f\u7684\u3001\u660e\u786e\u7684\u3002\u4e2d\u65b9\u5e0c\u671b\u5404\u65b9\u63a8\u52a8\u7f13\u548c\u5c40\u52bf\u3001\u81f4\u529b\u4e8e\u653f\u6cbb\u89e3\u51b3\u4e4c\u514b\u5170\u5371\u673a\u7684\u7acb\u573a\u6ca1\u6709\u6539\u53d8\uff0c\u5e76\u5c06\u7ee7\u7eed\u4e3a\u6b64\u53d1\u6325\u5efa\u8bbe\u6027\u4f5c\u7528\u3002 \u8fd4\u56de\u641c\u72d0\uff0c\u67e5\u770b\u66f4\u591a\n\n\u8d23\u4efb\u7f16\u8f91\uff1a \u6bb7\u745e\u6c11 UN949\n----\n" - } - ], + "inputs": [], "llm_id": "deepseek-chat@DeepSeek", "max_tokens": 0, "message_history_window_size": 12, - "output": { - "content": { - "0": "# Putin Approves New Russian Nuclear Deterrence Policy, China Responds\n\nIn a recent routine press conference on November 20th, a reporter inquired about two significant events: Russian President Vladimir Putin's approval of the new basic policy on Russia's nuclear deterrence, and the subsequent missile attack by Ukrainian forces on the Bryansk region of Russia. The reporter sought China's stance on these developments.\n\nOn November 19th, President Putin signed a decree approving the updated policy for Russia's nuclear deterrence. The document states that Russia views nuclear weapons as a means of deterrence and that their use would be an extreme measure taken under compulsion. On the same day, the Bryansk region was targeted by six U.S.-made missiles launched by Ukrainian forces. According to a report from the Russian Defense Ministry, all six missiles were intercepted by Russia's air defense systems, with debris falling within a military area in Bryansk.\n\nIn response to these events, Chinese Foreign Ministry spokesperson Lin Jian stated that China has taken note of the relevant reports. In the current context, all parties should remain calm and restrained, engaging in dialogue and consultation to jointly promote de-escalation and reduce strategic risks.\n\nLin emphasized that China's position on the Ukraine issue has been consistent and clear. China hopes that all parties will work towards easing tensions and pursuing political resolution of the Ukraine crisis. China remains committed to playing a constructive role in this regard." - } - }, "output_var_name": "output", "parameters": [ { @@ -154,28 +115,10 @@ "params": { "cite": false, "frequency_penalty": 0.7, - "inputs": [ - { - "component_id": "begin@lang", - "content": "English" - }, - { - "component_id": "begin@file", - "content": "https://www.sohu.com/a/828560323_162522?edtsign=70AF5B785A09DF20C126EABC2EC4FB4ABA309622&edtcode=2PBU%2BTiMwCHq%2FwmFSXvzFA%3D%3D&scm=10001.663_14-200000.0.10006.&_f=index_cpc_1_0&spm=smpc.channel_258.block4_314_Y6ubu8_1_fd.11.1732094805514oPmAsKj_1090\n\u666e\u4eac\u6279\u51c6\u65b0\u7248\u4fc4\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\uff0c\u5916\u4ea4\u90e8\u56de\u5e94_\u5e03\u826f\u65af_\u7f8e\u5236_\u4e2d\u65b9\n\u3010\u73af\u7403\u65f6\u62a5-\u73af\u7403\u7f51\u62a5\u9053 \u8bb0\u8005 \u767d\u4e91\u6021\u3011\u572811\u670820\u65e5\u5916\u4ea4\u90e8\u4f8b\u884c\u8bb0\u8005\u4f1a\u4e0a\uff0c\u6709\u8bb0\u8005\u63d0\u95ee\u79f0\uff0c\u4fc4\u7f57\u65af\u603b\u7edf\u666e\u4eac19\u65e5\u7b7e\u7f72\u603b\u7edf\u4ee4\uff0c\u6279\u51c6\u65b0\u7248\u4fc4\u7f57\u65af\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\u3002\u6587\u4ef6\u79f0\uff0c\u4fc4\u7f57\u65af\u89c6\u6838\u6b66\u5668\u4e3a\u4e00\u79cd\u5a01\u6151\u624b\u6bb5\uff0c\u4f7f\u7528\u6838\u6b66\u5668\u662f\u6781\u7aef\u60c5\u51b5\u4e0b\u88ab\u8feb\u91c7\u53d6\u7684\u63aa\u65bd\u3002\u540c\u65e5\uff0c\u4fc4\u5e03\u826f\u65af\u514b\u5dde\u906d\u5230\u4e4c\u519b6\u679a\u7f8e\u5236\u5bfc\u5f39\u88ad\u51fb\u3002\u4fc4\u56fd\u9632\u90e8\u7684\u901a\u62a5\u79f0\uff0c\u7ecf\u786e\u8ba4\uff0c\u4e4c\u65b9\u4f7f\u7528\u7684\u662f\u7f8e\u5236\u9646\u519b\u6218\u672f\u5bfc\u5f39\u7cfb\u7edf\uff0c6\u679a\u5bfc\u5f39\u5168\u90e8\u88ab\u4fc4\u519b\u9632\u7a7a\u7cfb\u7edf\u62e6\u622a\uff0c\u5bfc\u5f39\u6b8b\u7247\u843d\u5165\u5e03\u826f\u65af\u514b\u5dde\u4e00\u5904\u519b\u4e8b\u533a\u57df\u5185\u3002\u4e2d\u65b9\u5bf9\u8fd9\u4e24\u4ef6\u4e8b\u60c5\u6709\u4f55\u8bc4\u8bba\uff1f\n\n\u5bf9\u6b64\uff0c\u4e2d\u56fd\u5916\u4ea4\u90e8\u53d1\u8a00\u4eba\u6797\u5251\u8868\u793a\uff0c\u6211\u4eec\u6ce8\u610f\u5230\u4e86\u6709\u5173\u62a5\u9053\u3002\u5f53\u524d\u5f62\u52bf\u4e0b\uff0c\u5404\u65b9\u5e94\u5f53\u4fdd\u6301\u51b7\u9759\u514b\u5236\uff0c\u901a\u8fc7\u5bf9\u8bdd\u534f\u5546\u5171\u540c\u63a8\u52a8\u5c40\u52bf\u7f13\u548c\uff0c\u51cf\u5c11\u6218\u7565\u98ce\u9669\u3002\n\n\u6797\u5251\u5f3a\u8c03\uff0c\u5728\u4e4c\u514b\u5170\u95ee\u9898\u4e0a\uff0c\u4e2d\u65b9\u7684\u7acb\u573a\u662f\u4e00\u8d2f\u7684\u3001\u660e\u786e\u7684\u3002\u4e2d\u65b9\u5e0c\u671b\u5404\u65b9\u63a8\u52a8\u7f13\u548c\u5c40\u52bf\u3001\u81f4\u529b\u4e8e\u653f\u6cbb\u89e3\u51b3\u4e4c\u514b\u5170\u5371\u673a\u7684\u7acb\u573a\u6ca1\u6709\u6539\u53d8\uff0c\u5e76\u5c06\u7ee7\u7eed\u4e3a\u6b64\u53d1\u6325\u5efa\u8bbe\u6027\u4f5c\u7528\u3002 \u8fd4\u56de\u641c\u72d0\uff0c\u67e5\u770b\u66f4\u591a\n\n\u8d23\u4efb\u7f16\u8f91\uff1a \u6bb7\u745e\u6c11 UN949\n----\n" - }, - { - "component_id": "Generate:RichWordsDeny", - "content": " - # Putin Approves New Russian Nuclear Deterrence Policy, China Responds\n\nIn a recent routine press conference on November 20th, a reporter inquired about two significant events: Russian President Vladimir Putin's approval of the new basic policy on Russia's nuclear deterrence, and the subsequent missile attack by Ukrainian forces on the Bryansk region of Russia. The reporter sought China's stance on these developments.\n\nOn November 19th, President Putin signed a decree approving the updated policy for Russia's nuclear deterrence. The document states that Russia views nuclear weapons as a means of deterrence and that their use would be an extreme measure taken under compulsion. On the same day, the Bryansk region was targeted by six U.S.-made missiles launched by Ukrainian forces. According to a report from the Russian Defense Ministry, all six missiles were intercepted by Russia's air defense systems, with debris falling within a military area in Bryansk.\n\nIn response to these events, Chinese Foreign Ministry spokesperson Lin Jian stated that China has taken note of the relevant reports. In the current context, all parties should remain calm and restrained, engaging in dialogue and consultation to jointly promote de-escalation and reduce strategic risks.\n\nLin emphasized that China's position on the Ukraine issue has been consistent and clear. China hopes that all parties will work towards easing tensions and pursuing political resolution of the Ukraine crisis. China remains committed to playing a constructive role in this regard." - } - ], + "inputs": [], "llm_id": "deepseek-chat@DeepSeek", "max_tokens": 0, "message_history_window_size": 12, - "output": { - "content": { - "0": "1. **Accuracy**: The translation incorrectly states \"Chinese Foreign Ministry spokesperson Lin Jian\" instead of \"Chinese Foreign Ministry spokesperson Lin Jian.\" The correct name is \"Lin Jian,\" not \"Lin Jian.\"\n\n2. **Fluency**: The phrase \"In a recent routine press conference on November 20th, a reporter inquired about two significant events\" can be more fluently translated as \"During a regular press conference on November 20th, a reporter asked about two significant events.\"\n\n3. **Fluency**: The sentence \"The reporter sought China's stance on these developments\" can be improved to read more naturally: \"The reporter asked for China's position on these developments.\"\n\n4. **Style**: The phrase \"China has taken note of the relevant reports\" could be more stylistically aligned with the source text by using: \"We have noted the relevant reports.\"\n\n5. **Terminology**: The term \"Bryansk region\" should be consistently used throughout the translation instead of switching between \"Bryansk region\" and \"Bryansk.\"" - } - }, "output_var_name": "output", "parameters": [ { @@ -223,14 +166,14 @@ "name": "Target Language", "optional": false, "type": "line", - "value": "English" + "value": "" }, { "key": "file", "name": "Files", "optional": false, "type": "file", - "value": "https://www.sohu.com/a/828560323_162522?edtsign=70AF5B785A09DF20C126EABC2EC4FB4ABA309622&edtcode=2PBU%2BTiMwCHq%2FwmFSXvzFA%3D%3D&scm=10001.663_14-200000.0.10006.&_f=index_cpc_1_0&spm=smpc.channel_258.block4_314_Y6ubu8_1_fd.11.1732094805514oPmAsKj_1090\n\u666e\u4eac\u6279\u51c6\u65b0\u7248\u4fc4\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\uff0c\u5916\u4ea4\u90e8\u56de\u5e94_\u5e03\u826f\u65af_\u7f8e\u5236_\u4e2d\u65b9\n\u3010\u73af\u7403\u65f6\u62a5-\u73af\u7403\u7f51\u62a5\u9053 \u8bb0\u8005 \u767d\u4e91\u6021\u3011\u572811\u670820\u65e5\u5916\u4ea4\u90e8\u4f8b\u884c\u8bb0\u8005\u4f1a\u4e0a\uff0c\u6709\u8bb0\u8005\u63d0\u95ee\u79f0\uff0c\u4fc4\u7f57\u65af\u603b\u7edf\u666e\u4eac19\u65e5\u7b7e\u7f72\u603b\u7edf\u4ee4\uff0c\u6279\u51c6\u65b0\u7248\u4fc4\u7f57\u65af\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\u3002\u6587\u4ef6\u79f0\uff0c\u4fc4\u7f57\u65af\u89c6\u6838\u6b66\u5668\u4e3a\u4e00\u79cd\u5a01\u6151\u624b\u6bb5\uff0c\u4f7f\u7528\u6838\u6b66\u5668\u662f\u6781\u7aef\u60c5\u51b5\u4e0b\u88ab\u8feb\u91c7\u53d6\u7684\u63aa\u65bd\u3002\u540c\u65e5\uff0c\u4fc4\u5e03\u826f\u65af\u514b\u5dde\u906d\u5230\u4e4c\u519b6\u679a\u7f8e\u5236\u5bfc\u5f39\u88ad\u51fb\u3002\u4fc4\u56fd\u9632\u90e8\u7684\u901a\u62a5\u79f0\uff0c\u7ecf\u786e\u8ba4\uff0c\u4e4c\u65b9\u4f7f\u7528\u7684\u662f\u7f8e\u5236\u9646\u519b\u6218\u672f\u5bfc\u5f39\u7cfb\u7edf\uff0c6\u679a\u5bfc\u5f39\u5168\u90e8\u88ab\u4fc4\u519b\u9632\u7a7a\u7cfb\u7edf\u62e6\u622a\uff0c\u5bfc\u5f39\u6b8b\u7247\u843d\u5165\u5e03\u826f\u65af\u514b\u5dde\u4e00\u5904\u519b\u4e8b\u533a\u57df\u5185\u3002\u4e2d\u65b9\u5bf9\u8fd9\u4e24\u4ef6\u4e8b\u60c5\u6709\u4f55\u8bc4\u8bba\uff1f\n\n\u5bf9\u6b64\uff0c\u4e2d\u56fd\u5916\u4ea4\u90e8\u53d1\u8a00\u4eba\u6797\u5251\u8868\u793a\uff0c\u6211\u4eec\u6ce8\u610f\u5230\u4e86\u6709\u5173\u62a5\u9053\u3002\u5f53\u524d\u5f62\u52bf\u4e0b\uff0c\u5404\u65b9\u5e94\u5f53\u4fdd\u6301\u51b7\u9759\u514b\u5236\uff0c\u901a\u8fc7\u5bf9\u8bdd\u534f\u5546\u5171\u540c\u63a8\u52a8\u5c40\u52bf\u7f13\u548c\uff0c\u51cf\u5c11\u6218\u7565\u98ce\u9669\u3002\n\n\u6797\u5251\u5f3a\u8c03\uff0c\u5728\u4e4c\u514b\u5170\u95ee\u9898\u4e0a\uff0c\u4e2d\u65b9\u7684\u7acb\u573a\u662f\u4e00\u8d2f\u7684\u3001\u660e\u786e\u7684\u3002\u4e2d\u65b9\u5e0c\u671b\u5404\u65b9\u63a8\u52a8\u7f13\u548c\u5c40\u52bf\u3001\u81f4\u529b\u4e8e\u653f\u6cbb\u89e3\u51b3\u4e4c\u514b\u5170\u5371\u673a\u7684\u7acb\u573a\u6ca1\u6709\u6539\u53d8\uff0c\u5e76\u5c06\u7ee7\u7eed\u4e3a\u6b64\u53d1\u6325\u5efa\u8bbe\u6027\u4f5c\u7528\u3002 \u8fd4\u56de\u641c\u72d0\uff0c\u67e5\u770b\u66f4\u591a\n\n\u8d23\u4efb\u7f16\u8f91\uff1a \u6bb7\u745e\u6c11 UN949\n----\n" + "value": "" } ] } @@ -305,14 +248,14 @@ "name": "Target Language", "optional": false, "type": "line", - "value": "English" + "value": "" }, { "key": "file", "name": "Files", "optional": false, "type": "file", - "value": "https://www.sohu.com/a/828560323_162522?edtsign=70AF5B785A09DF20C126EABC2EC4FB4ABA309622&edtcode=2PBU%2BTiMwCHq%2FwmFSXvzFA%3D%3D&scm=10001.663_14-200000.0.10006.&_f=index_cpc_1_0&spm=smpc.channel_258.block4_314_Y6ubu8_1_fd.11.1732094805514oPmAsKj_1090\n\u666e\u4eac\u6279\u51c6\u65b0\u7248\u4fc4\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\uff0c\u5916\u4ea4\u90e8\u56de\u5e94_\u5e03\u826f\u65af_\u7f8e\u5236_\u4e2d\u65b9\n\u3010\u73af\u7403\u65f6\u62a5-\u73af\u7403\u7f51\u62a5\u9053 \u8bb0\u8005 \u767d\u4e91\u6021\u3011\u572811\u670820\u65e5\u5916\u4ea4\u90e8\u4f8b\u884c\u8bb0\u8005\u4f1a\u4e0a\uff0c\u6709\u8bb0\u8005\u63d0\u95ee\u79f0\uff0c\u4fc4\u7f57\u65af\u603b\u7edf\u666e\u4eac19\u65e5\u7b7e\u7f72\u603b\u7edf\u4ee4\uff0c\u6279\u51c6\u65b0\u7248\u4fc4\u7f57\u65af\u6838\u5a01\u6151\u56fd\u5bb6\u57fa\u672c\u653f\u7b56\u3002\u6587\u4ef6\u79f0\uff0c\u4fc4\u7f57\u65af\u89c6\u6838\u6b66\u5668\u4e3a\u4e00\u79cd\u5a01\u6151\u624b\u6bb5\uff0c\u4f7f\u7528\u6838\u6b66\u5668\u662f\u6781\u7aef\u60c5\u51b5\u4e0b\u88ab\u8feb\u91c7\u53d6\u7684\u63aa\u65bd\u3002\u540c\u65e5\uff0c\u4fc4\u5e03\u826f\u65af\u514b\u5dde\u906d\u5230\u4e4c\u519b6\u679a\u7f8e\u5236\u5bfc\u5f39\u88ad\u51fb\u3002\u4fc4\u56fd\u9632\u90e8\u7684\u901a\u62a5\u79f0\uff0c\u7ecf\u786e\u8ba4\uff0c\u4e4c\u65b9\u4f7f\u7528\u7684\u662f\u7f8e\u5236\u9646\u519b\u6218\u672f\u5bfc\u5f39\u7cfb\u7edf\uff0c6\u679a\u5bfc\u5f39\u5168\u90e8\u88ab\u4fc4\u519b\u9632\u7a7a\u7cfb\u7edf\u62e6\u622a\uff0c\u5bfc\u5f39\u6b8b\u7247\u843d\u5165\u5e03\u826f\u65af\u514b\u5dde\u4e00\u5904\u519b\u4e8b\u533a\u57df\u5185\u3002\u4e2d\u65b9\u5bf9\u8fd9\u4e24\u4ef6\u4e8b\u60c5\u6709\u4f55\u8bc4\u8bba\uff1f\n\n\u5bf9\u6b64\uff0c\u4e2d\u56fd\u5916\u4ea4\u90e8\u53d1\u8a00\u4eba\u6797\u5251\u8868\u793a\uff0c\u6211\u4eec\u6ce8\u610f\u5230\u4e86\u6709\u5173\u62a5\u9053\u3002\u5f53\u524d\u5f62\u52bf\u4e0b\uff0c\u5404\u65b9\u5e94\u5f53\u4fdd\u6301\u51b7\u9759\u514b\u5236\uff0c\u901a\u8fc7\u5bf9\u8bdd\u534f\u5546\u5171\u540c\u63a8\u52a8\u5c40\u52bf\u7f13\u548c\uff0c\u51cf\u5c11\u6218\u7565\u98ce\u9669\u3002\n\n\u6797\u5251\u5f3a\u8c03\uff0c\u5728\u4e4c\u514b\u5170\u95ee\u9898\u4e0a\uff0c\u4e2d\u65b9\u7684\u7acb\u573a\u662f\u4e00\u8d2f\u7684\u3001\u660e\u786e\u7684\u3002\u4e2d\u65b9\u5e0c\u671b\u5404\u65b9\u63a8\u52a8\u7f13\u548c\u5c40\u52bf\u3001\u81f4\u529b\u4e8e\u653f\u6cbb\u89e3\u51b3\u4e4c\u514b\u5170\u5371\u673a\u7684\u7acb\u573a\u6ca1\u6709\u6539\u53d8\uff0c\u5e76\u5c06\u7ee7\u7eed\u4e3a\u6b64\u53d1\u6325\u5efa\u8bbe\u6027\u4f5c\u7528\u3002 \u8fd4\u56de\u641c\u72d0\uff0c\u67e5\u770b\u66f4\u591a\n\n\u8d23\u4efb\u7f16\u8f91\uff1a \u6bb7\u745e\u6c11 UN949\n----\n" + "value": "" } ] }, diff --git a/api/apps/sdk/session.py b/api/apps/sdk/session.py index 7d376bdfd1..522c3028fb 100644 --- a/api/apps/sdk/session.py +++ b/api/apps/sdk/session.py @@ -77,7 +77,7 @@ def create_agent_session(tenant_id, agent_id): conv = { "id": get_uuid(), "dialog_id": cvs.id, - "user_id": req.get("usr_id",""), + "user_id": req.get("usr_id","") if isinstance(req, dict) else "", "message": [{"role": "assistant", "content": canvas.get_prologue()}], "source": "agent" } @@ -345,7 +345,7 @@ def sse(): API4ConversationService.append_message(conv.id, conv.to_dict()) except Exception as e: cvs.dsl = json.loads(str(canvas)) - UserCanvasService.update_by_id(req["id"], cvs.to_dict()) + API4ConversationService.append_message(conv.id, conv.to_dict()) yield "data:" + json.dumps({"code": 500, "message": str(e), "data": {"answer": "**ERROR**: " + str(e), "reference": []}}, ensure_ascii=False) + "\n\n" @@ -365,7 +365,6 @@ def sse(): if final_ans.get("reference"): canvas.reference.append(final_ans["reference"]) cvs.dsl = json.loads(str(canvas)) - UserCanvasService.update_by_id(req["id"], cvs.to_dict()) result = {"answer": final_ans["content"], "reference": final_ans.get("reference", [])} fillin_conv(result)