app: description: 对新闻打上人为灾害事件 icon: ✉️ icon_background: '#E0F2FE' mode: workflow name: 新闻标签与翻译-火山DeepseekV3-v0.2 use_icon_as_answer_icon: false dependencies: - current_identifier: null type: marketplace value: marketplace_plugin_unique_identifier: langgenius/volcengine_maas:0.0.10@ba0a7fc3151e89bf8645cd3abb3ccff971ee59e5b1127efca50b092dbb93bf80 kind: app version: 0.1.5 workflow: conversation_variables: [] environment_variables: [] features: file_upload: allowed_file_extensions: - .JPG - .JPEG - .PNG - .GIF - .WEBP - .SVG allowed_file_types: - image allowed_file_upload_methods: - local_file - remote_url enabled: false fileUploadConfig: audio_file_size_limit: 50 batch_count_limit: 5 file_size_limit: 15 image_file_size_limit: 10 video_file_size_limit: 100 workflow_file_upload_limit: 10 image: enabled: false number_limits: 3 transfer_methods: - local_file - remote_url number_limits: 3 opening_statement: '' retriever_resource: enabled: false sensitive_word_avoidance: enabled: false speech_to_text: enabled: false suggested_questions: [] suggested_questions_after_answer: enabled: false text_to_speech: enabled: false language: '' voice: '' graph: edges: - data: isInIteration: false sourceType: code targetType: end id: 1727242813814-source-1727235861736-target source: '1727242813814' sourceHandle: source target: '1727235861736' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: start targetType: llm id: 1727233123593-source-1732778846154-target source: '1727233123593' sourceHandle: source target: '1732778846154' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false sourceType: llm targetType: code id: 1732778846154-source-1727242813814-target source: '1732778846154' sourceHandle: source target: '1727242813814' targetHandle: target type: custom zIndex: 0 nodes: - data: desc: "{\n \"msg_info\": \"DeryckWhibley坚称他'不是骗子',前经理否认了性胁迫指控\",\n \"sys.files\"\ : [],\n \"sys.user_id\": \"sl_backend_twitter\"\n}" selected: false title: 开始 type: start variables: - label: msg_info max_length: 2000 options: [] required: true type: paragraph variable: msg_info height: 197 id: '1727233123593' position: x: -61.60583804915933 y: 291.69166477189617 positionAbsolute: x: -61.60583804915933 y: 291.69166477189617 selected: false sourcePosition: right targetPosition: left type: custom width: 243 - data: desc: '' outputs: - value_selector: - '1727242813814' - result variable: result selected: false title: 结束 type: end height: 89 id: '1727235861736' position: x: 1122.9814661452995 y: 304.9033674451216 positionAbsolute: x: 1122.9814661452995 y: 304.9033674451216 selected: false sourcePosition: right targetPosition: left type: custom width: 243 - data: code: "news_tag_dict = {\n\"枪击\":\"TagShooting\",\n\"抢劫\":\"TagRobbery\",\n\ \"爆炸\":\"TagExplosion\",\n\"恐怖袭击\":\"TagTerroristAttack\",\n\"纵火\":\"TagArson\"\ ,\n\"大规模伤亡事件\":\"TagMassCasualtyIncident\",\n\"人质事件\":\"TagHostageSituation\"\ ,\n\"毒气泄漏\":\"TagToxicGasLeak\",\n\"生物危害\":\"TagBiologicalHazard\",\n\"\ 交通意外\":\"TagTrafficAccident\",\n\"建筑物倒塌\":\"TagBuildingCollapse\",\n\"食品安全\"\ :\"TagFoodSafety\",\n\"社会冲突\":\"TagSocialConflict\",\n\"群体性事件\":\"TagMassGatheringIncident\"\ ,\n\"环境污染\":\"TagEnvironmentalPollution\",\n\"重大事故\":\"TagMajorAccident\"\ ,\n\"抗议示威\":\"TagProtestDemonstration\",\n\"集体维权\":\"TagCollectiveAdvocacy\"\ ,\n\"活动失控骚乱\":\"TagUncontrolledEventRiot\",\n\"地域冲突\":\"TagTerritorialConflict\"\ ,\n\"性别冲突\":\"TagGenderConflict\",\n\"宗教冲突\":\"TagReligiousConflict\",\n\ \"民族冲突\":\"TagEthnicConflict\",\n\"阶级冲突\":\"TagClassConflict\",\n\"食物中毒\"\ :\"TagFoodPoisoning\",\n\"公共卫生事件\":\"PublicHealthEmergency\",\n\"环境污染\"\ :\"TagEnvironmentalPollution\",\n\"活动失控骚乱\":\"TagUncontrolledEventRiot\"\ ,\n\"抗议示威\":\"TagProtestDemonstration\",\n\"工业事故\":\"IndustriaAccident\"\ ,\n\"核事故\":\"NuclearAccident\",\n\"性别冲突\":\"TagGenderConflict\",\n\"矿难\"\ :\"MiningAccident\",\n\"游行抗议\":\"Protest\",\n\"水坝溃坝\":\"DamBurst\",\n\"\ 油轮泄漏\":\"OilSpill\",\n\"火灾\":\"Fire\"\n}\n\ndef main(kn_result: dict) ->\ \ dict:\n print(kn_result)\n kn_result = kn_result.replace(\"输出:\"\ ,\"\")\n kn_result = kn_result.replace(\"```json\", \"\").replace(\"\ ```\", \"\").strip()\n data = json.loads(kn_result)\n converted_data\ \ = []\n for item in data:\n new_item = item.copy() # 创建副本以避免修改原始数据\n\ \ if \"news_tag\" in new_item:\n new_item[\"news_tag\"\ ] = convert_tags(item[\"news_tag\"], news_tag_dict)\n converted_data.append(new_item)\n\ \ return {\n \"result\": converted_data,\n }\n \ndef convert_item(item):\n\ \ item[\"news_tag\"] = [news_tag_dict.get(tag, tag) for tag in item[\"\ news_tag\"]]\n return item\n\ndef convert_tags(tag_list, mapping_dict):\n\ \ converted = []\n for tag in tag_list:\n if tag in mapping_dict:\n\ \ converted.append({\n \"code\": mapping_dict[tag],\n\ \ \"name\": tag\n })\n return converted\n\n\ \ \n \n" code_language: python3 desc: '' outputs: result: children: null type: array[object] selected: true title: KnResult2Obj type: code variables: - value_selector: - '1732778846154' - text variable: kn_result height: 53 id: '1727242813814' position: x: 665.0284314948408 y: 291.69166477189617 positionAbsolute: x: 665.0284314948408 y: 291.69166477189617 selected: true sourcePosition: right targetPosition: left type: custom width: 243 - data: context: enabled: false variable_selector: [] desc: '' model: completion_params: top_p: 0.7 mode: chat name: deepseek-v3-250324 provider: langgenius/volcengine_maas/volcengine_maas prompt_template: - id: ff06405d-dfb9-40ca-987a-c24fd3cfd6fb role: system text: "```xml\n<instruction>\n同时对多条新闻内容进行打上新闻标签分类和翻译成指定语言,仅当新闻标签评分达到或超过80分时才应用新闻标签,翻译必须进行,每条数据都唯一标识ID。输入为JSON数组,输出也为JSON数组。具体要求如下:\n\ \n1. **输入格式**: \n - 输入是一个JSON数组,每个对象包含以下字段: \n - `content`:新闻内容文本\ \ \n - `id`:唯一标识ID \n - `language`:目标翻译语言 \n\n2. **输出格式**:\ \ \n - 输出是一个JSON数组,每个对象包含以下字段:\n - `content`:翻译后的新闻内容 \n -\ \ `id`:与输入相同的唯一标识ID \n - `language`:目标翻译语言 \n - `news_tag`:新闻标签列表(仅当评分≥80分时应用)\ \ \n\n3. **标签分类规则**: \n - 新闻标签的评分范围为0-100分,仅当评分≥80分时才将标签添加到输出中。\ \ \n - 翻译必须执行,无论标签评分如何。 \n\n4. **标签列表**: \n - 人为灾害标签包括:枪击,抢劫,事故爆炸,恐怖袭击,纵火,大规模伤亡事件,人质事件,毒气泄漏,生物危害,交通事故,建筑物倒塌,食品安全事件,社会冲突,群体性事件,环境污染,抗议示威,集体维权,活动失控骚乱,地域冲突,性别冲突,宗教冲突,民族冲突,阶级冲突,食物中毒,地震,火山爆发,山体滑坡,泥石流,雪崩,水坝决口,水坝溃坝,台风/飓风,龙卷风,暴雨,洪水,寒潮,高温热浪,干旱,沙尘暴,冻雨,冰雹,雷暴,大风,山林火灾,冰川融化,海啸,霾,化学品泄漏,核事故,矿难,油轮泄漏,火灾,工业污染,工业事故,传染病爆发,公共卫生事件,持刀伤人,恐怖爆炸,暴力冲突,战争,游行抗议,其他。\n\ \n5. **注意事项**: \n - 输出中不得包含任何XML标签。 \n - 确保每条数据的唯一标识ID与输入一致。 \n\ \ - 如果新闻内容无法分类或评分低于80分,则输出“其他”。\n</instruction>\n```" - id: 9f485eef-bc41-4f14-b8dd-9d507b6a8d3d role: user text: '{{#1727233123593.msg_info#}}' selected: false title: LLM type: llm variables: [] vision: enabled: false height: 89 id: '1732778846154' position: x: 239.00707979814337 y: 291.69166477189617 positionAbsolute: x: 239.00707979814337 y: 291.69166477189617 selected: false sourcePosition: right targetPosition: left type: custom width: 243 viewport: x: -123.24134866557824 y: -47.25645747214685 zoom: 0.946852837930634