Browse Source

Imagetcha modolar version

Shellmiao 1 year ago
parent
commit
bf6f7825e6
60 changed files with 1481 additions and 1 deletions
  1. 1 1
      config/format_config.json
  2. 108 0
      config/three_kingdoms_debug/module_output/GPT_event_output.json
  3. 48 0
      config/three_kingdoms_debug/module_output/GPT_input_output.json
  4. 8 0
      config/three_kingdoms_debug/module_output/GPT_value_output.json
  5. 5 0
      config/three_kingdoms_debug/module_output/Interact_choose_output.json
  6. 203 0
      config/three_kingdoms_debug/modules_config.json
  7. 5 0
      config/three_kingdoms_debug/prompt/event_1.json
  8. 5 0
      config/three_kingdoms_debug/prompt/event_2.json
  9. 5 0
      config/three_kingdoms_debug/prompt/event_3.json
  10. 5 0
      config/three_kingdoms_debug/prompt/input.json
  11. 3 0
      config/three_kingdoms_debug/prompt/json_declare.json
  12. 5 0
      config/three_kingdoms_debug/prompt/value_1.json
  13. 5 0
      config/three_kingdoms_debug/prompt/value_2.json
  14. 4 0
      config/three_kingdoms_debug/user_input.json
  15. 163 0
      config/three_kingdoms_product/module_output/GPT_event_output.json
  16. 39 0
      config/three_kingdoms_product/module_output/GPT_input_output.json
  17. 7 0
      config/three_kingdoms_product/module_output/GPT_value_output.json
  18. 21 0
      config/three_kingdoms_product/module_output/Interact_choose_output.json
  19. 203 0
      config/three_kingdoms_product/modules_config.json
  20. 5 0
      config/three_kingdoms_product/prompt/event_1.json
  21. 6 0
      config/three_kingdoms_product/prompt/event_2.json
  22. 5 0
      config/three_kingdoms_product/prompt/event_3.json
  23. 5 0
      config/three_kingdoms_product/prompt/input.json
  24. 3 0
      config/three_kingdoms_product/prompt/json_declare.json
  25. 5 0
      config/three_kingdoms_product/prompt/value_1.json
  26. 5 0
      config/three_kingdoms_product/prompt/value_2.json
  27. 4 0
      config/three_kingdoms_product/user_input.json
  28. 22 0
      config/three_kingdoms_test/module_output/GPT_event_output.json
  29. 43 0
      config/three_kingdoms_test/module_output/GPT_input_output.json
  30. 7 0
      config/three_kingdoms_test/module_output/GPT_value_output.json
  31. 5 0
      config/three_kingdoms_test/module_output/Interact_choose_output.json
  32. 203 0
      config/three_kingdoms_test/modules_config.json
  33. 5 0
      config/three_kingdoms_test/prompt/event_1.json
  34. 6 0
      config/three_kingdoms_test/prompt/event_2.json
  35. 5 0
      config/three_kingdoms_test/prompt/event_3.json
  36. 5 0
      config/three_kingdoms_test/prompt/input.json
  37. 3 0
      config/three_kingdoms_test/prompt/json_declare.json
  38. 5 0
      config/three_kingdoms_test/prompt/value_1.json
  39. 5 0
      config/three_kingdoms_test/prompt/value_2.json
  40. 4 0
      config/three_kingdoms_test/user_input.json
  41. 70 0
      main_module.py
  42. 6 0
      modules/conditional_judgement_module.py
  43. 45 0
      modules/gpt_module.py
  44. 16 0
      modules/interact_module.py
  45. 0 0
      non_module_old/Evaluate_langchain.py
  46. 0 0
      non_module_old/README.md
  47. 0 0
      non_module_old/config/evaluate_config.json
  48. 0 0
      non_module_old/config/event_config.json
  49. 0 0
      non_module_old/config/input_config.json
  50. 0 0
      non_module_old/config/value_config.json
  51. 0 0
      non_module_old/event_langchain.py
  52. 0 0
      non_module_old/format_langchain.py
  53. 0 0
      non_module_old/global_langchain.py
  54. 0 0
      non_module_old/input_main.py
  55. 0 0
      non_module_old/main_langchain.py
  56. BIN
      non_module_old/my_database.db
  57. 0 0
      non_module_old/value_langchain.py
  58. 0 0
      old/api/openai_api.py
  59. 103 0
      utils/configuration.py
  60. 42 0
      utils/format_error_data.py

+ 1 - 1
config/format_config.json

@@ -1,4 +1,4 @@
 {
-    "system_template": "将输入字符串转为可以使用json.load读取的字符串,格式如下{output_type},key值和value的类型以上述格式为准,不要输出除了json字符串之外的其他内容",
+    "system_template": "将输入字符串转为可以使用json.load读取的字符串,不要输出除了json字符串之外的其他内容",
     "human_template": "{text}"
 }

+ 108 - 0
config/three_kingdoms_debug/module_output/GPT_event_output.json

@@ -0,0 +1,108 @@
+{
+    "class_output_data": [
+        {
+            "事件": "你和其他黄巾军士兵一起在山林中行进,突然听到前方传来了阵阵喊杀声,你们赶紧上前查看,发现是一支曹军正在袭击一支吴军,你们决定...",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "前去救援吴军",
+                "趁机抢夺曹军的物资",
+                "躲避战斗,绕路前行"
+            ],
+            "当前场景角色": [
+                {
+                    "名字": "摸鱼",
+                    "特征": "黄巾军士兵,墨家子弟,年龄16岁"
+                },
+                {
+                    "名字": "张角",
+                    "特征": "黄巾军领袖,号称“太平道教主”"
+                },
+                {
+                    "名字": "刘备",
+                    "特征": "蜀汉开国皇帝,仁德之君"
+                },
+                {
+                    "名字": "曹操",
+                    "特征": "魏国开国皇帝,奸诈狡猾"
+                },
+                {
+                    "名字": "孙权",
+                    "特征": "吴国开国皇帝,英明果断"
+                }
+            ],
+            "当前场景数值系统": [
+                {
+                    "名称": "武力",
+                    "范围": "0-100",
+                    "含义": "影响战斗力和攻击力"
+                },
+                {
+                    "名称": "智力",
+                    "范围": "0-100",
+                    "含义": "影响策略和谋略"
+                },
+                {
+                    "名称": "魅力",
+                    "范围": "0-100",
+                    "含义": "影响交际和人际关系"
+                },
+                {
+                    "名称": "体力",
+                    "范围": "0-100",
+                    "含义": "影响生命值和耐力"
+                }
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你和其他黄巾军士兵一起在山林中行进,突然听到前方传来了阵阵喊杀声,你们赶紧上前查看,发现是一支曹军正在袭击一支吴军,你们决定趁机抢夺曹军的物资。你们成功地抢到了一些粮食和草药,但是在离开的时候被曹军发现了,你们只好迅速逃跑。",
+            "是否需要玩家选择下一步操作": false,
+            "玩家可以做出的选择": [],
+            "当前场景角色": [
+                {
+                    "名字": "摸鱼",
+                    "特征": "黄巾军士兵,墨家子弟,年龄16岁"
+                },
+                {
+                    "名字": "张角",
+                    "特征": "黄巾军领袖,号称“太平道教主”"
+                },
+                {
+                    "名字": "刘备",
+                    "特征": "蜀汉开国皇帝,仁德之君"
+                },
+                {
+                    "名字": "曹操",
+                    "特征": "魏国开国皇帝,奸诈狡猾"
+                },
+                {
+                    "名字": "孙权",
+                    "特征": "吴国开国皇帝,英明果断"
+                }
+            ],
+            "当前场景数值系统": [
+                {
+                    "名称": "武力",
+                    "范围": "0-100",
+                    "含义": "影响战斗力和攻击力"
+                },
+                {
+                    "名称": "智力",
+                    "范围": "0-100",
+                    "含义": "影响策略和谋略"
+                },
+                {
+                    "名称": "魅力",
+                    "范围": "0-100",
+                    "含义": "影响交际和人际关系"
+                },
+                {
+                    "名称": "体力",
+                    "范围": "0-100",
+                    "含义": "影响生命值和耐力"
+                }
+            ],
+            "游戏是否结束": false
+        }
+    ]
+}

+ 48 - 0
config/three_kingdoms_debug/module_output/GPT_input_output.json

@@ -0,0 +1,48 @@
+{
+    "故事简介": "在混乱的三国时代,你扮演一名黄巾军士兵,名叫摸鱼,是一名墨家子弟。你将经历一系列搞笑的冒险,成为一名真正的英雄。",
+    "角色设定": [
+        {
+            "名字": "摸鱼",
+            "特征": "黄巾军士兵,墨家子弟,年龄16岁"
+        },
+        {
+            "名字": "张角",
+            "特征": "黄巾军领袖,号称“太平道教主”"
+        },
+        {
+            "名字": "刘备",
+            "特征": "蜀汉开国皇帝,仁德之君"
+        },
+        {
+            "名字": "曹操",
+            "特征": "魏国开国皇帝,奸诈狡猾"
+        },
+        {
+            "名字": "孙权",
+            "特征": "吴国开国皇帝,英明果断"
+        }
+    ],
+    "数值系统": [
+        {
+            "名称": "武力",
+            "范围": "0-100",
+            "含义": "影响战斗力和攻击力"
+        },
+        {
+            "名称": "智力",
+            "范围": "0-100",
+            "含义": "影响策略和谋略"
+        },
+        {
+            "名称": "魅力",
+            "范围": "0-100",
+            "含义": "影响交际和人际关系"
+        },
+        {
+            "名称": "体力",
+            "范围": "0-100",
+            "含义": "影响生命值和耐力"
+        }
+    ],
+    "游戏通关所需条件": "成为三国时代的一名真正英雄,统一天下,实现太平盛世。"
+}

+ 8 - 0
config/three_kingdoms_debug/module_output/GPT_value_output.json

@@ -0,0 +1,8 @@
+{
+    "value": {
+        "武力": 70,
+        "智力": 35,
+        "魅力": 25,
+        "体力": 60
+    }
+}

+ 5 - 0
config/three_kingdoms_debug/module_output/Interact_choose_output.json

@@ -0,0 +1,5 @@
+{
+    "class_output_data": [
+        "趁机抢夺曹军的物资"
+    ]
+}

+ 203 - 0
config/three_kingdoms_debug/modules_config.json

@@ -0,0 +1,203 @@
+{
+    "GPT": [
+        {
+            "class": "input",
+            "id": 1,
+            "input": {
+                "user_input": "user_input.json",
+                "input_module_prompt":"prompt/input.json",
+                "json_declare":"prompt/json_declare.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "declare":"input_module_prompt['declare']",
+                "json_declare":"json_declare['json_declare']"
+            },
+            "prompt": "prompt/input.json",
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 1
+            }
+        },
+        {
+            "class": "value",
+            "id": 1,
+            "input": {
+                "intro": "module_output/GPT_input_output.json",
+                "value_1_module_prompt":"prompt/value_1.json"
+            },
+            "prompt_input":{
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"value_1_module_prompt['output_type']"
+            },
+            "prompt": "prompt/value_1.json",
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "GPT",
+                "class": "event",
+                "id": 1
+            }
+        },
+        {
+            "class": "event",
+            "id": 1,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_1.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']"
+            },
+            "prompt": "prompt/event_1.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        },
+        {
+            "class": "value",
+            "id": 2,
+            "input": {
+                "intro": "module_output/GPT_input_output.json",
+                "value_1_module_prompt":"prompt/value_1.json",
+                "value": "module_output/GPT_value_output.json",
+                "event": "module_output/GPT_event_output.json"
+            },
+            "prompt": "prompt/value_2.json",
+            "prompt_input":{
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "event":"event['class_output_data']",
+                "value":"value['value']",
+                "output_type":"value_1_module_prompt['output_type']"
+            },
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "Judgement",
+                "class": "Boolean",
+                "id": 1
+            }
+        },
+        {
+            "class": "event",
+            "id": 2,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_2.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json",
+                "event": "module_output/GPT_event_output.json",
+                "interact":"module_output/Interact_choose_output.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']",
+                "event":"event['class_output_data']",
+                "interact":"interact['class_output_data']"
+            },
+            "prompt": "prompt/event_2.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        },
+        {
+            "class": "event",
+            "id": 3,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_2.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json",
+                "event": "module_output/GPT_event_output.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']",
+                "event":"event['class_output_data']"
+            },
+            "prompt": "prompt/event_2.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        }
+    ],
+    "Judgement": [
+        {
+            "class": "Boolean",
+            "id": 1,
+            "input": {
+                "event": "module_output/GPT_event_output.json"
+            },
+            "value":"event['class_output_data'][-1]['是否需要玩家选择下一步操作']",
+            "if_true_next": {
+                "type": "Interact",
+                "class": "choose",
+                "id": 1
+            },
+            "if_false_next": {
+                "type": "GPT",
+                "class": "event",
+                "id": 3
+            }
+        }
+    ],
+    "Interact": [
+        {
+            "class": "choose",
+            "id": 1,
+            "input": {
+                "event": "module_output/GPT_event_output.json"
+            },
+            "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "event",
+                "id": 2
+            }
+        }
+    ]
+}

+ 5 - 0
config/three_kingdoms_debug/prompt/event_1.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"当前场景角色\": \"数组格式,游戏中的npc角色设定,包括角色的名字、特征\",\"当前场景数值系统\": \"数组格式,数值系统包括游戏中的数值名称、数值范围、数值含义,例如装备系统、官职系统等;允许由于故事的发展而添加新的数值\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value},你的json输出为{json_declare}:"
+}

+ 5 - 0
config/three_kingdoms_debug/prompt/event_2.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"当前场景角色\": \"数组格式,游戏中的npc角色设定,包括角色的名字、特征\",\"当前场景数值系统\": \"数组格式,数值系统包括游戏中的数值名称、数值范围、数值含义,例如装备系统、官职系统等;允许由于故事的发展而添加新的数值\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value};游戏发生的事件:{event};玩家对最后一次事件做出的选择:{interact};你的json输出为{json_declare}:"
+}

+ 5 - 0
config/three_kingdoms_debug/prompt/event_3.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"当前场景角色\": \"数组格式,游戏中的npc角色设定,包括角色的名字、特征\",\"当前场景数值系统\": \"数组格式,数值系统包括游戏中的数值名称、数值范围、数值含义,例如装备系统、官职系统等;允许由于故事的发展而添加新的数值\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value};游戏发生的事件:{event};你的json输出为{json_declare}:"
+}

+ 5 - 0
config/three_kingdoms_debug/prompt/input.json

@@ -0,0 +1,5 @@
+{
+    "declare":"{'故事简介': '字符串格式,这是展示给玩家的故事简介与游戏目标','角色设定': '数组格式,游戏中的npc角色设定,包括角色的名字、特征;不包含玩家所操控的角色','数值系统': '数组格式,数值系统包括游戏中的数值名称、数值范围、数值含义,例如装备系统、官职系统等','游戏通关所需条件': '字符串格式,游戏结束的条件,例如“成为了诸侯王'}",
+    "system_template": "以如下格式输出可以被json.loads读取的JSON字符串:{declare}",
+    "human_template": "我希望生成一个文字冒险游戏,以下是对游戏故事的要求:故事风格:{style},故事参考:{story}。你生成的可以直接被json.loads读取的不带换行符的JSON字符串为{json_declare}:"
+}

+ 3 - 0
config/three_kingdoms_debug/prompt/json_declare.json

@@ -0,0 +1,3 @@
+{
+    "json_declare":"(示例:{\"key\":\"value\"})"
+}

+ 5 - 0
config/three_kingdoms_debug/prompt/value_1.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"value\":{\"数值名称\":\"数值大小\"}",
+    "system_template": "输出JSON",
+    "human_template": "我正在生成一个文字游戏,故事简介:{intro};角色设定:{npc};数值系统:{value_system};游戏通关所需条件:{target};需要你根据游戏当前信息对玩家数值进行初始化,不用输出除了value之外的其他内容,你的JSON输出为{output_type}:"
+}

+ 5 - 0
config/three_kingdoms_debug/prompt/value_2.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"value\":{\"数值名称\":\"数值大小\"}",
+    "system_template": "输出JSON",
+    "human_template": "我正在生成一个文字游戏,故事简介:{intro};角色设定:{npc};数值系统:{value_system};游戏通关所需条件:{target};游戏发生的事件:{event};玩家当前数值:{value};需要你根据游戏最后发生的事件对玩家数值进行修改,不用输出除了value之外的其他内容,你的JSON输出为{output_type}:"
+}

+ 4 - 0
config/three_kingdoms_debug/user_input.json

@@ -0,0 +1,4 @@
+{
+    "style": "三国,搞笑",
+    "story": "始于黄巾起义的混乱时代,我叫摸鱼,是黄巾军的一员,也是一名墨家子弟,年龄16岁"
+}

+ 163 - 0
config/three_kingdoms_product/module_output/GPT_event_output.json

@@ -0,0 +1,163 @@
+{
+    "class_output_data": [
+        {
+            "事件": "你跟随黄巾军攻打一座城池,城内守军顽强抵抗,你被派去破坏城墙,你发现城墙上有一个机关,你可以选择使用自己的机关制造技能修复它,或者直接攻击城墙",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "修复机关",
+                "攻击城墙"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你成功修复了城墙上的机关,城墙被破坏,你们顺利攻入城内。在城内,你遇到了一位墨家弟子,他向你表示愿意加入黄巾军,你可以选择接受他的加入或者拒绝他",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "接受加入",
+                "拒绝加入"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你接受了墨家弟子的加入,他向你展示了他的机关制造技能,你们开始合作制造更加先进的武器和防具。在一次战斗中,你们成功地使用了一种新型弩车,大大提高了黄巾军的战斗力。曹操听闻了你们的战绩,派人前来招揽你们,你可以选择加入曹操的麾下,或者继续留在黄巾军",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "加入曹操",
+                "留在黄巾军"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你加入了曹操的麾下,成为他的部下。曹操对你的机关制造技能非常赞赏,让你负责制造更加先进的武器和防具。在一次战斗中,你们成功地使用了一种新型投石车,大大提高了魏军的战斗力。刘备听闻了你们的战绩,派人前来招揽你们,你可以选择加入刘备的麾下,或者继续留在曹操的军队",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "加入刘备",
+                "留在曹操军队"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你加入了刘备的麾下,成为他的部下。刘备对你的机关制造技能非常赞赏,让你负责制造更加先进的武器和防具。在一次战斗中,你们成功地使用了一种新型火药,大大提高了蜀军的战斗力。曹操听闻了你们的战绩,派人前来招揽你们,你可以选择加入曹操的麾下,或者继续留在刘备的军队",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "加入曹操",
+                "留在刘备军队"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你加入了曹操的麾下,成为他的部下。曹操对你的机关制造技能非常赞赏,让你负责制造更加先进的武器和防具。在一次战斗中,你们成功地使用了一种新型投石车,大大提高了魏军的战斗力。这时,曹操派你前往一座山寨,消灭山寨中的叛军。你可以选择带上你的机关制造师兄弟,或者独自前往",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "带上机关制造师兄弟",
+                "独自前往"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你独自前往山寨,途中遇到了一位神秘的道士。道士自称是张角的弟子,他告诉你张角正在寻找一位能够制造出更加先进机关的人才,他邀请你加入黄巾军,成为张角的部下。你可以选择加入黄巾军,或者继续前往山寨消灭叛军",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "加入黄巾军",
+                "继续前往山寨"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你到达了山寨,发现反军已经被暹汽的部队消测了。但是你发现山寨中有一批机具装置,看起来非常先进。你可以选择将这些机具装带回暹汽的军队,或者将它们留给黄川军",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "带回暹汽的军队",
+                "留给黄川军"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你成功将机具装置带回了暹汽的军队,曹操对你的贡献非常满意,晋升你为机关制造部门的负责人。你开始着手研发更加先进的机关装备,帮助魏国在战争中取得更多的胜利。在一次试验中,你发现了一种新型机关装置,可以大幅提高魏军的攻击力和防御力。曹操决定将这种机关装置用于下一次攻城战,你需要带领机关制造团队将这种机关装置制造出来。你可以选择加班加点完成制造,或者招募更多的工匠来帮助你",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "加班加点完成制造",
+                "招募更多的工匠"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你和机关制造团队加班加点,终于在最后一刻完成了新型机关装置的制造。曹操非常满意,决定在下一次攻城战中使用这种机关装置。但是,你发现这种机关装置的制造需要大量的资源和人力,你需要想办法解决这个问题。你可以选择向曹操请求更多的资源和人力,或者想办法自己解决",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "向曹操请求更多的资源和人力",
+                "想办法自己解决"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你决定自己解决机关装置制造所需要资源和人力问题。你想到了一个功力,可以通过制造和贩卡机关置来赞取足够的资金和资源。你开始着手制造机关置,并在市场上贩卡。但是,你很快发现市场上已经有很多人在贩卡。你需要想力功能改进机关置的性能,或者降低价格来吸引更多的买家",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "改进机关置的性能",
+                "降低价格来吸引更多的买家"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你成功改进了机关置的性能,使其更加高效和稳定。你的机关置开始受到更多人的关注和购买,你的财富和资源也随之增加。曹操对你的贡献非常满意,晋升你为机关制造部门的总负责人。你开始着手研发更加先进的机关装备,帮助魏国在战争中取得更多的胜利。在一次试验中,你发现了一种新型机关装置,可以大幅提高魏军的攻击力和防御力。曹操决定将这种机关装置用于下一次攻城战,你需要带领机关制造团队将这种机关装置制造出来。你可以选择加班加点完成制造,或者招募更多的工匠来帮助你",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "加班加点完成制造",
+                "招募更多的工匠"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你和机关制造团队开始加班加点,全力制造新型机关装置。在经过几天的努力后,你们终于在最后一刻完成了制造。曹操非常满意,决定在下一次攻城战中使用这种机关装置。但是,你们的身体状况已经非常糟糕,需要休息和调养。你可以选择休息一段时间,或者继续工作",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "休息一段时间",
+                "继续工作"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你和机关制造图队体继续工作,但是身体犹私情越来越糕情,有些人已经开始生病。曹操非常着惊,他需要这种机关装置来赞得下一场战争。他给你施工了很大的压力,让你必须在规定时间内完成制造。你需要决定是否继续加班加点,或者停止工作让大家休息",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "继续加班加点",
+                "停止工作让大家休息"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你和机关制造团队继续加班加点,身体状况越来越糟糕,有些人已经无法坚持下去。在最后一天,你们终于完成了机关装置的制造。曹操非常满意,决定在下一场攻城战中使用这种机关装置。但是,你们的身体已经到了极限,需要休息和调养。你可以选择休息一段时间,或者继续工作。",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "休息一段时间",
+                "继续工作"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你和机关制造团队休息了一段时间,身体状况得到了一定的恢复。但是,曹操需要你们继续制造更多的机关装置,以备不时之需。你需要决定是否继续工作,或者拒绝曹操的要求",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "继续工作",
+                "拒绝曹操的要求"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你和机关制造团队继续加班加点,身体状况越来越糟糕,有些人已经无法坚持下去。在制造过程中,你发现了一个机关装置的设计缺陷,如果不及时修复,可能会导致机关装置在战斗中失灵。你需要决定是否继续加班加点,或者停下来修复设计缺陷。",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "继续加班加点",
+                "停下来修复设计缺陷"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你决定停下来修复机关装置的设计缺陷。经过一番修复,机关装置终于得以完美地制造出来。曹操非常满意,决定在下一场攻城战中使用这种机关装。你的机关制造团队也因为这次成功的制造者而被曹操的赛车评估。",
+            "是否需要玩家选择下一步操作": false,
+            "玩家可以做出的选择": [],
+            "游戏是否结束": false
+        }
+    ]
+}

+ 39 - 0
config/three_kingdoms_product/module_output/GPT_input_output.json

@@ -0,0 +1,39 @@
+{
+    "故事简介": "在混乱的三国时代,你扮演一名黄巾军士兵,名叫摸鱼。作为一名墨家子弟,你有着不同于其他士兵的思想和行为。在这个充满战争和政治斗争的时代,你将如何生存和发展自己的事业呢?",
+    "角色设定": [
+        {
+            "名字": "摸鱼",
+            "特征": "墨家子弟,思想独特,擅长机关制造"
+        },
+        {
+            "名字": "张角",
+            "特征": "黄巾军领袖,号称太平道人,擅长道术"
+        },
+        {
+            "名字": "曹操",
+            "特征": "魏国开国皇帝,政治手腕高超,擅长用兵"
+        },
+        {
+            "名字": "刘备",
+            "特征": "蜀国开国皇帝,仁义之君,擅长招兵买马"
+        }
+    ],
+    "数值系统": [
+        {
+            "名称": "武力值",
+            "范围": "0-100",
+            "含义": "影响战斗力和攻击力"
+        },
+        {
+            "名称": "智力值",
+            "范围": "0-100",
+            "含义": "影响策略和谋略的成功率"
+        },
+        {
+            "名称": "魅力值",
+            "范围": "0-100",
+            "含义": "影响交际和招募npc的成功率"
+        }
+    ],
+    "游戏通关所需条件": "成为三国霸主,统一天下!"
+}

+ 7 - 0
config/three_kingdoms_product/module_output/GPT_value_output.json

@@ -0,0 +1,7 @@
+{
+    "value": {
+        "武力值": 90,
+        "智力值": 70,
+        "魅力值": 80
+    }
+}

+ 21 - 0
config/three_kingdoms_product/module_output/Interact_choose_output.json

@@ -0,0 +1,21 @@
+{
+    "class_output_data": [
+        "修复机关",
+        "接受加入",
+        "加入曹操",
+        "加入刘备",
+        "加入曹操",
+        "独自前往",
+        "继续前往山寨",
+        "带回暹汽的军队",
+        "加班加点完成制造",
+        "想办法自己解决",
+        "改进机关置的性能",
+        "加班加点完成制造",
+        "继续工作",
+        "继续加班加点",
+        "休息一段时间",
+        "继续工作",
+        "停下来修复设计缺陷"
+    ]
+}

+ 203 - 0
config/three_kingdoms_product/modules_config.json

@@ -0,0 +1,203 @@
+{
+    "GPT": [
+        {
+            "class": "input",
+            "id": 1,
+            "input": {
+                "user_input": "user_input.json",
+                "input_module_prompt":"prompt/input.json",
+                "json_declare":"prompt/json_declare.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "declare":"input_module_prompt['declare']",
+                "json_declare":"json_declare['json_declare']"
+            },
+            "prompt": "prompt/input.json",
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 1
+            }
+        },
+        {
+            "class": "value",
+            "id": 1,
+            "input": {
+                "intro": "module_output/GPT_input_output.json",
+                "value_1_module_prompt":"prompt/value_1.json"
+            },
+            "prompt_input":{
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"value_1_module_prompt['output_type']"
+            },
+            "prompt": "prompt/value_1.json",
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "GPT",
+                "class": "event",
+                "id": 1
+            }
+        },
+        {
+            "class": "event",
+            "id": 1,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_1.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']"
+            },
+            "prompt": "prompt/event_1.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        },
+        {
+            "class": "value",
+            "id": 2,
+            "input": {
+                "intro": "module_output/GPT_input_output.json",
+                "value_1_module_prompt":"prompt/value_1.json",
+                "value": "module_output/GPT_value_output.json",
+                "event": "module_output/GPT_event_output.json"
+            },
+            "prompt": "prompt/value_2.json",
+            "prompt_input":{
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "event":"event['class_output_data']",
+                "value":"value['value']",
+                "output_type":"value_1_module_prompt['output_type']"
+            },
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "Judgement",
+                "class": "Boolean",
+                "id": 1
+            }
+        },
+        {
+            "class": "event",
+            "id": 2,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_2.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json",
+                "event": "module_output/GPT_event_output.json",
+                "interact":"module_output/Interact_choose_output.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']",
+                "event":"event['class_output_data'][-3:]",
+                "interact":"interact['class_output_data'][-1]"
+            },
+            "prompt": "prompt/event_2.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        },
+        {
+            "class": "event",
+            "id": 3,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_3.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json",
+                "event": "module_output/GPT_event_output.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']",
+                "event":"event['class_output_data'][-3:]"
+            },
+            "prompt": "prompt/event_3.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        }
+    ],
+    "Judgement": [
+        {
+            "class": "Boolean",
+            "id": 1,
+            "input": {
+                "event": "module_output/GPT_event_output.json"
+            },
+            "value":"event['class_output_data'][-1]['是否需要玩家选择下一步操作']",
+            "if_true_next": {
+                "type": "Interact",
+                "class": "choose",
+                "id": 1
+            },
+            "if_false_next": {
+                "type": "GPT",
+                "class": "event",
+                "id": 3
+            }
+        }
+    ],
+    "Interact": [
+        {
+            "class": "choose",
+            "id": 1,
+            "input": {
+                "event": "module_output/GPT_event_output.json"
+            },
+            "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "event",
+                "id": 2
+            }
+        }
+    ]
+}

+ 5 - 0
config/three_kingdoms_product/prompt/event_1.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value},玩家遇到的下一个事件的json输出为{json_declare}:"
+}

+ 6 - 0
config/three_kingdoms_product/prompt/event_2.json

@@ -0,0 +1,6 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value};游戏发生的事件:{event};玩家对最后一次事件做出的选择:{interact};玩家遇到的下一个事件的json输出为{json_declare}:"
+    
+}

+ 5 - 0
config/three_kingdoms_product/prompt/event_3.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value};游戏发生的事件:{event};玩家遇到的下一个事件的json输出为{json_declare}:"
+}

+ 5 - 0
config/three_kingdoms_product/prompt/input.json

@@ -0,0 +1,5 @@
+{
+    "declare":"{'故事简介': '字符串格式,这是展示给玩家的故事简介与游戏目标','角色设定': '数组格式,游戏中的npc角色设定,包括角色的名字、特征;不包含玩家所操控的角色','数值系统': '数组格式,数值系统包括游戏中的数值名称、数值范围、数值含义,例如装备系统、官职系统等','游戏通关所需条件': '字符串格式,游戏结束的条件,例如“成为了诸侯王'}",
+    "system_template": "以如下格式输出可以被json.loads读取的JSON字符串:{declare}",
+    "human_template": "我希望生成一个文字冒险游戏,以下是对游戏故事的要求:故事风格:{style},故事参考:{story}。你生成的可以直接被json.loads读取的不带换行符的JSON字符串为{json_declare}:"
+}

+ 3 - 0
config/three_kingdoms_product/prompt/json_declare.json

@@ -0,0 +1,3 @@
+{
+    "json_declare":"(示例:{\"key1\":\"value1\",\"key2\":\"value2\"})"
+}

+ 5 - 0
config/three_kingdoms_product/prompt/value_1.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "示例:{\"value\":{\"数值名称\":\"数值大小\"}",
+    "system_template": "输出JSON",
+    "human_template": "我正在生成一个文字游戏,故事简介:{intro};角色设定:{npc};数值系统:{value_system};游戏通关所需条件:{target};需要你根据游戏当前信息对玩家数值进行初始化,不用输出除了value之外的其他内容,你的JSON输出为{output_type}:"
+}

+ 5 - 0
config/three_kingdoms_product/prompt/value_2.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"value\":{\"数值名称\":\"数值大小\"}",
+    "system_template": "输出JSON",
+    "human_template": "我正在生成一个文字游戏,故事简介:{intro};角色设定:{npc};数值系统:{value_system};游戏通关所需条件:{target};游戏发生的事件:{event};玩家当前数值:{value};需要你根据游戏最后发生的事件对玩家数值进行修改,不用输出除了value之外的其他内容,你的JSON输出为{output_type}:"
+}

+ 4 - 0
config/three_kingdoms_product/user_input.json

@@ -0,0 +1,4 @@
+{
+    "style": "三国,搞笑",
+    "story": "始于黄巾起义的混乱时代,我叫摸鱼,是黄巾军的一员,也是一名墨家子弟,年龄16岁"
+}

+ 22 - 0
config/three_kingdoms_test/module_output/GPT_event_output.json

@@ -0,0 +1,22 @@
+{
+    "class_output_data": [
+        {
+            "事件": "你跟随着黄巾军的队伍一路向南,来到了一片茂密的森林前。张角道长拍了拍你的肩膀,说道:“小兄弟,这片森林里有一只凶猛的猛虎,我们需要你去猎杀它,展现你的勇气!”你心里有些害怕,但也不想在众人面前失面子,于是你决定……",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "前往森林深处寻找猛虎",
+                "留在原地观望"
+            ],
+            "游戏是否结束": false
+        },
+        {
+            "事件": "你决定留在原地观望,看看其他人的表现。突然,一声巨响传来,你发现张角道长已经率领其他人前往森林深处了。你赶紧跟上去,却发现张角道长已经被一只凶猛的猛虎攻击。你需要快速做出决定,救援张角道长还是猛攻猛虎?",
+            "是否需要玩家选择下一步操作": true,
+            "玩家可以做出的选择": [
+                "救援张角道长",
+                "猛攻猛虎"
+            ],
+            "游戏是否结束": false
+        }
+    ]
+}

+ 43 - 0
config/three_kingdoms_test/module_output/GPT_input_output.json

@@ -0,0 +1,43 @@
+{
+    "故事简介": "在混乱的三国时代,你扮演一名名叫摸鱼的黄巾军士兵,同时也是一名墨家子弟。年仅16岁的你,将会经历一系列搞笑的冒险,与各路英雄豪杰交手,最终成为一名真正的英雄。",
+    "角色设定": [
+        {
+            "名字": "摸鱼",
+            "特征": "黄巾军士兵,墨家子弟,年仅16岁"
+        },
+        {
+            "名字": "张角",
+            "特征": "黄巾军领袖,号称“太平道人”"
+        },
+        {
+            "名字": "曹操",
+            "特征": "魏国开国皇帝,智勇双全,是三国时期的重要人物之一"
+        },
+        {
+            "名字": "刘备",
+            "特征": "蜀汉开国皇帝,仁义之君,是三国时期的重要人物之一"
+        },
+        {
+            "名字": "孙权",
+            "特征": "吴国开国皇帝,善于用人,是三国时期的重要人物之一"
+        }
+    ],
+    "数值系统": [
+        {
+            "名称": "武力值",
+            "范围": "0-100",
+            "含义": "影响战斗力"
+        },
+        {
+            "名称": "智力值",
+            "范围": "0-100",
+            "含义": "影响策略和谈判能力"
+        },
+        {
+            "名称": "魅力值",
+            "范围": "0-100",
+            "含义": "影响人际关系和交际能力"
+        }
+    ],
+    "游戏通关所需条件": "成为三国时代的一名真正英雄,统一天下,实现太平盛世。"
+}

+ 7 - 0
config/three_kingdoms_test/module_output/GPT_value_output.json

@@ -0,0 +1,7 @@
+{
+    "value": {
+        "武力值": 70,
+        "智力值": 50,
+        "魅力值": 50
+    }
+}

+ 5 - 0
config/three_kingdoms_test/module_output/Interact_choose_output.json

@@ -0,0 +1,5 @@
+{
+    "class_output_data": [
+        "留在原地观望"
+    ]
+}

+ 203 - 0
config/three_kingdoms_test/modules_config.json

@@ -0,0 +1,203 @@
+{
+    "GPT": [
+        {
+            "class": "input",
+            "id": 1,
+            "input": {
+                "user_input": "user_input.json",
+                "input_module_prompt":"prompt/input.json",
+                "json_declare":"prompt/json_declare.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "declare":"input_module_prompt['declare']",
+                "json_declare":"json_declare['json_declare']"
+            },
+            "prompt": "prompt/input.json",
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 1
+            }
+        },
+        {
+            "class": "value",
+            "id": 1,
+            "input": {
+                "intro": "module_output/GPT_input_output.json",
+                "value_1_module_prompt":"prompt/value_1.json"
+            },
+            "prompt_input":{
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"value_1_module_prompt['output_type']"
+            },
+            "prompt": "prompt/value_1.json",
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "GPT",
+                "class": "event",
+                "id": 1
+            }
+        },
+        {
+            "class": "event",
+            "id": 1,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_1.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']"
+            },
+            "prompt": "prompt/event_1.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        },
+        {
+            "class": "value",
+            "id": 2,
+            "input": {
+                "intro": "module_output/GPT_input_output.json",
+                "value_1_module_prompt":"prompt/value_1.json",
+                "value": "module_output/GPT_value_output.json",
+                "event": "module_output/GPT_event_output.json"
+            },
+            "prompt": "prompt/value_2.json",
+            "prompt_input":{
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "event":"event['class_output_data']",
+                "value":"value['value']",
+                "output_type":"value_1_module_prompt['output_type']"
+            },
+            "output": "{class_output_data}",
+            "next_module": {
+                "type": "Judgement",
+                "class": "Boolean",
+                "id": 1
+            }
+        },
+        {
+            "class": "event",
+            "id": 2,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_2.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json",
+                "event": "module_output/GPT_event_output.json",
+                "interact":"module_output/Interact_choose_output.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']",
+                "event":"event['class_output_data'][-3:]",
+                "interact":"interact['class_output_data'][-1]"
+            },
+            "prompt": "prompt/event_2.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        },
+        {
+            "class": "event",
+            "id": 3,
+            "input": {
+                "user_input": "user_input.json",
+                "event_module_prompt":"prompt/event_3.json",
+                "intro": "module_output/GPT_input_output.json",
+                "value": "module_output/GPT_value_output.json",
+                "json_declare":"prompt/json_declare.json",
+                "event": "module_output/GPT_event_output.json"
+            },
+            "prompt_input":{
+                "style":"user_input['style']",
+                "story":"user_input['story']",
+                "intro":"intro['故事简介']",
+                "npc":"intro['角色设定']",
+                "value_system":"intro['数值系统']",
+                "target":"intro['游戏通关所需条件']",
+                "output_type":"event_module_prompt['output_type']",
+                "json_declare":"json_declare['json_declare']",
+                "value":"value['value']",
+                "event":"event['class_output_data'][-3:]"
+            },
+            "prompt": "prompt/event_3.json",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "value",
+                "id": 2
+            }
+        }
+    ],
+    "Judgement": [
+        {
+            "class": "Boolean",
+            "id": 1,
+            "input": {
+                "event": "module_output/GPT_event_output.json"
+            },
+            "value":"event['class_output_data'][-1]['是否需要玩家选择下一步操作']",
+            "if_true_next": {
+                "type": "Interact",
+                "class": "choose",
+                "id": 1
+            },
+            "if_false_next": {
+                "type": "GPT",
+                "class": "event",
+                "id": 3
+            }
+        }
+    ],
+    "Interact": [
+        {
+            "class": "choose",
+            "id": 1,
+            "input": {
+                "event": "module_output/GPT_event_output.json"
+            },
+            "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
+            "output": "{class_output_data_append}",
+            "next_module": {
+                "type": "GPT",
+                "class": "event",
+                "id": 2
+            }
+        }
+    ]
+}

+ 5 - 0
config/three_kingdoms_test/prompt/event_1.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value},玩家遇到的下一个事件的json输出为{json_declare}:"
+}

+ 6 - 0
config/three_kingdoms_test/prompt/event_2.json

@@ -0,0 +1,6 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value};游戏发生的事件:{event};玩家对最后一次事件做出的选择:{interact};玩家遇到的下一个事件的json输出为{json_declare}:"
+    
+}

+ 5 - 0
config/three_kingdoms_test/prompt/event_3.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"事件\": \"字符串格式,这是展示给玩家的,讲述了玩家当前遇到的事件,例如“0岁,你出生于颍川一个富贵之家...”。出现新的人物时需要在事件中对新的人物进行描写,并在当前角色设定中添加新的角色\",\"是否需要玩家选择下一步操作\": \"Boolean格式\",\"玩家可以做出的选择\": \"数组格式,玩家可以做出的有限个选择,如果不需要玩家做选择则返回空数组\",\"游戏是否结束\": \"Boolean格式,游戏是否结束\"}",
+    "system_template": "我正在生成一个文字冒险游戏,我将输入游戏当前信息与当前游戏的风格、简介,需要你根据游戏当前信息生成玩家接下来遇到的下一个事件,以如下格式输出JSON:{output_type},严格按照格式输出,不要输出除了json字符串之外的其他内容",
+    "human_template": "游戏风格:{style};游戏参考:{story};故事简介:{intro};角色设定:{npc};数值系统:{value_system};当前数值:{value};游戏发生的事件:{event};玩家遇到的下一个事件的json输出为{json_declare}:"
+}

+ 5 - 0
config/three_kingdoms_test/prompt/input.json

@@ -0,0 +1,5 @@
+{
+    "declare":"{'故事简介': '字符串格式,这是展示给玩家的故事简介与游戏目标','角色设定': '数组格式,游戏中的npc角色设定,包括角色的名字、特征;不包含玩家所操控的角色','数值系统': '数组格式,数值系统包括游戏中的数值名称、数值范围、数值含义,例如装备系统、官职系统等','游戏通关所需条件': '字符串格式,游戏结束的条件,例如“成为了诸侯王'}",
+    "system_template": "以如下格式输出可以被json.loads读取的JSON字符串:{declare}",
+    "human_template": "我希望生成一个文字冒险游戏,以下是对游戏故事的要求:故事风格:{style},故事参考:{story}。你生成的可以直接被json.loads读取的不带换行符的JSON字符串为{json_declare}:"
+}

+ 3 - 0
config/three_kingdoms_test/prompt/json_declare.json

@@ -0,0 +1,3 @@
+{
+    "json_declare":"(示例:{\"key1\":\"value1\",\"key2\":\"value2\"})"
+}

+ 5 - 0
config/three_kingdoms_test/prompt/value_1.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "示例:{\"value\":{\"数值名称\":\"数值大小\"}",
+    "system_template": "输出JSON",
+    "human_template": "我正在生成一个文字游戏,故事简介:{intro};角色设定:{npc};数值系统:{value_system};游戏通关所需条件:{target};需要你根据游戏当前信息对玩家数值进行初始化,不用输出除了value之外的其他内容,你的JSON输出为{output_type}:"
+}

+ 5 - 0
config/three_kingdoms_test/prompt/value_2.json

@@ -0,0 +1,5 @@
+{
+    "output_type": "{\"value\":{\"数值名称\":\"数值大小\"}",
+    "system_template": "输出JSON",
+    "human_template": "我正在生成一个文字游戏,故事简介:{intro};角色设定:{npc};数值系统:{value_system};游戏通关所需条件:{target};游戏发生的事件:{event};玩家当前数值:{value};需要你根据游戏最后发生的事件对玩家数值进行修改,不用输出除了value之外的其他内容,你的JSON输出为{output_type}:"
+}

+ 4 - 0
config/three_kingdoms_test/user_input.json

@@ -0,0 +1,4 @@
+{
+    "style": "三国,搞笑",
+    "story": "始于黄巾起义的混乱时代,我叫摸鱼,是黄巾军的一员,也是一名墨家子弟,年龄16岁"
+}

+ 70 - 0
main_module.py

@@ -0,0 +1,70 @@
+from modules.conditional_judgement_module import judgment_module
+from modules.gpt_module import gpt_module
+from modules.interact_module import interact_module
+from utils.configuration import Configuration
+
+configuration=Configuration('three_kingdoms_test')
+input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('input',1)
+prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+prompt=configuration.read_prompt(prompt_path)
+gpt_module('input',1,prompt_input_value,prompt,output)
+
+while True:
+    if next_module["type"]=="GPT":
+        input_path,prompt_input_declare,prompt_path,output,next_module_temp=configuration.read_gpt_config(next_module["class"],next_module["id"])
+        prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+        prompt=configuration.read_prompt(prompt_path)
+        gpt_module(next_module["class"],next_module["id"],prompt_input_value,prompt,output)
+        next_module=next_module_temp
+
+    elif next_module["type"]=="Judgement":
+        input,value,judgement=configuration.read_judgement_config(next_module["class"],next_module["id"])
+        input_value=configuration.judgement_input_process(input,value)
+        next_module=judgment_module(next_module["class"],input_value,judgement)
+    elif next_module["type"]=="Interact":
+        input,choices,output,next_module_temp=configuration.read_interact_config(next_module["class"],next_module["id"])
+        choices_value=configuration.interact_input_process(input,choices)
+        interact_module(next_module["class"],next_module["id"],choices_value,output)
+        next_module=next_module_temp
+    else:
+        break
+
+
+# input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('input',1)
+# prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+# prompt=configuration.read_prompt(prompt_path)
+# gpt_module('input',1,prompt_input_value,prompt,output)
+
+# input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('value',1)
+# prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+# prompt=configuration.read_prompt(prompt_path)
+# gpt_module('value',1,prompt_input_value,prompt,output)
+
+# input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('event',1)
+# prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+# prompt=configuration.read_prompt(prompt_path)
+# gpt_module('event',1,prompt_input_value,prompt,output)
+
+# input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('value',2)
+# prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+# prompt=configuration.read_prompt(prompt_path)
+# gpt_module('value',2,prompt_input_value,prompt,output)
+
+# input,value,judgement=configuration.read_judgement_config('Boolean',1)
+# input_value=configuration.judgement_input_process(input,value)
+# result=judgment_module('Boolean',input_value,judgement)
+# if result["type"]=="Interact":
+#     input,choices,output=configuration.read_interact_config(result["class"],result["id"])
+#     choices_value=configuration.interact_input_process(input,choices)
+#     interact_module(result["class"],result["id"],choices_value,output)
+
+# input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('event',2)
+# prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+# prompt=configuration.read_prompt(prompt_path)
+# gpt_module('event',2,prompt_input_value,prompt,output)
+
+# input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('value',2)
+# prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
+# prompt=configuration.read_prompt(prompt_path)
+# gpt_module('value',2,prompt_input_value,prompt,output)
+

+ 6 - 0
modules/conditional_judgement_module.py

@@ -0,0 +1,6 @@
+def judgment_module(classname,value,Judgement):
+    if classname=="Boolean":
+        if value:
+            return Judgement["if_true_next"]
+        else:
+            return Judgement["if_false_next"]

+ 45 - 0
modules/gpt_module.py

@@ -0,0 +1,45 @@
+import json
+import os
+from langchain.chat_models import ChatOpenAI
+from langchain.prompts.chat import (
+    ChatPromptTemplate,
+    SystemMessagePromptTemplate,
+    HumanMessagePromptTemplate,
+)
+from utils.configuration import Configuration
+from utils.format_error_data import format_error_data
+from utils.utils import convert_choice
+
+
+def gpt_module(classname,id,input,prompt,output):
+    print('--------------------------GPT--------------------------')
+    chat = ChatOpenAI(temperature=0)
+
+    system_template = prompt["system_template"]
+    system_message_prompt = SystemMessagePromptTemplate.from_template(
+        system_template)
+    human_template = prompt["human_template"]
+    human_message_prompt = HumanMessagePromptTemplate.from_template(
+        human_template)
+
+    chat_prompt = ChatPromptTemplate.from_messages(
+        [system_message_prompt, human_message_prompt])
+
+    input_prompt=chat_prompt.format_prompt(**{key: value for key, value in input.items()}).to_messages()
+    print("输入prompt为:"+str(input_prompt))
+    rsp = chat(input_prompt)
+    try:
+        game_event = json.loads(rsp.content, object_hook=convert_choice)
+        print(game_event)
+        save_2_json(classname,id,output,game_event)
+    except:
+        print('JSON格式解析错误,GPT输出如下,尝试修复')
+        print(rsp.content)
+        game_event=format_error_data(rsp.content)
+        if game_event is not None:
+            save_2_json(classname,id,output,game_event)
+
+def save_2_json(classname,id,output_type,data):
+    configuration=Configuration()
+    file_path="GPT_"+classname+"_output.json"
+    configuration.save_2_json(file_path,output_type,data)

+ 16 - 0
modules/interact_module.py

@@ -0,0 +1,16 @@
+from utils.configuration import Configuration
+
+
+def interact_module(classname,id,choices,output_type):
+    print("'--------------------------Interact--------------------------'")
+    for i, choice in enumerate(choices, 1):
+        print(f"{i}:{choice}")
+    choose_num=int(input("[选择]输入选择对应数字:"))
+    choose=choices[choose_num-1]
+    save_2_json(classname,id,output_type,choose)
+
+
+def save_2_json(classname,id,output_type,data):
+    configuration=Configuration()
+    file_path="Interact_"+classname+"_output.json"
+    configuration.save_2_json(file_path,output_type,data)

+ 0 - 0
Evaluate_langchain.py → non_module_old/Evaluate_langchain.py


+ 0 - 0
README.md → non_module_old/README.md


+ 0 - 0
config/evaluate_config.json → non_module_old/config/evaluate_config.json


+ 0 - 0
config/event_config.json → non_module_old/config/event_config.json


+ 0 - 0
config/input_config.json → non_module_old/config/input_config.json


+ 0 - 0
config/value_config.json → non_module_old/config/value_config.json


+ 0 - 0
event_langchain.py → non_module_old/event_langchain.py


+ 0 - 0
format_langchain.py → non_module_old/format_langchain.py


+ 0 - 0
global_langchain.py → non_module_old/global_langchain.py


+ 0 - 0
input_main.py → non_module_old/input_main.py


+ 0 - 0
main_langchain.py → non_module_old/main_langchain.py


BIN
non_module_old/my_database.db


+ 0 - 0
value_langchain.py → non_module_old/value_langchain.py


+ 0 - 0
api/openai_api.py → old/api/openai_api.py


+ 103 - 0
utils/configuration.py

@@ -0,0 +1,103 @@
+import json
+import os
+
+def singleton(cls):
+    instances = {}
+
+    def wrapper(*args, **kwargs):
+        if cls not in instances:
+            instances[cls] = cls(*args, **kwargs)
+        return instances[cls]
+
+    return wrapper
+
+@singleton
+class Configuration:
+    def __init__(self, game_name):
+        self.game_name = game_name
+
+    def save_2_json(self,file_path,output_type,data):
+        if output_type=="{class_output_data}":
+            file_path='config/'+self.game_name+'/module_output/'+file_path
+            os.makedirs(os.path.dirname(file_path), exist_ok=True)
+            with open(file_path, 'w', encoding='utf-8') as f:
+                json.dump(data, f, ensure_ascii=False, indent=4)
+        elif output_type=="{class_output_data_append}":
+            file_path='config/'+self.game_name+'/module_output/'+file_path
+            os.makedirs(os.path.dirname(file_path), exist_ok=True)
+            if os.path.exists(file_path):
+                with open(file_path, 'r', encoding='utf-8') as f:
+                    existing_data = json.load(f)
+            else:
+                existing_data = {"class_output_data":[]}
+            existing_data["class_output_data"].append(data)
+            with open(file_path, 'w', encoding='utf-8') as f:
+                json.dump(existing_data, f, ensure_ascii=False, indent=4)
+        else:
+            file_path='config/'+self.game_name+'/module_output/'+file_path
+            os.makedirs(os.path.dirname(file_path), exist_ok=True)
+            if os.path.exists(file_path):
+                with open(file_path, 'r', encoding='utf-8') as f:
+                    existing_data = json.load(f)
+            else:
+                existing_data = {"class_output_data":[]}
+            existing_data["class_output_data"].append(data)
+            with open(file_path, 'w', encoding='utf-8') as f:
+                json.dump(data, f, ensure_ascii=False, indent=4)
+
+    def prompt_input_process(self,input,prompt_input):
+        for input_key, input_value in input.items():
+            with open('config/'+self.game_name+'/'+input_value,encoding='utf-8') as f:
+                globals()[input_key] = json.load(f)
+        prompt_input_values = {}
+        for prompt_input_key, prompt_input_value in prompt_input.items():
+            prompt_input_values[prompt_input_key] = eval(prompt_input_value.format(**locals()))
+        return prompt_input_values
+    
+    def read_prompt(self,prompt_path):
+        with open('config/'+self.game_name+'/'+prompt_path,encoding='utf-8') as f:
+            prompt = json.load(f)
+        return prompt
+
+    def read_gpt_config(self,classname,id):
+        with open('config/'+self.game_name+'/modules_config.json',encoding='utf-8') as f:
+            data = json.load(f)
+        gpts=data["GPT"]
+        for gpt in gpts:
+            if gpt["id"]==id and gpt["class"]==classname:
+                return gpt["input"],gpt["prompt_input"],gpt["prompt"],gpt["output"],gpt["next_module"]
+            
+    def read_judgement_config(self,classname,id):
+        with open('config/'+self.game_name+'/modules_config.json',encoding='utf-8') as f:
+            data = json.load(f)
+        judgements=data["Judgement"]
+        for judgement in judgements:
+            if judgement["id"]==id and judgement["class"]==classname:
+                return judgement["input"],judgement["value"],judgement
+
+    def judgement_input_process(self,input,value):
+        for input_key, input_value in input.items():
+            with open('config/'+self.game_name+'/'+input_value,encoding='utf-8') as f:
+                globals()[input_key] = json.load(f)
+        input_value = eval(value.format(**locals()))
+        return input_value
+    
+    def read_interact_config(self,classname,id):
+        with open('config/'+self.game_name+'/modules_config.json',encoding='utf-8') as f:
+            data = json.load(f)
+        interacts=data["Interact"]
+        for interact in interacts:
+            if interact["id"]==id and interact["class"]==classname:
+                return interact["input"],interact["choices"],interact["output"],interact["next_module"]
+
+    def interact_input_process(self,input,value):
+        for input_key, input_value in input.items():
+            with open('config/'+self.game_name+'/'+input_value,encoding='utf-8') as f:
+                globals()[input_key] = json.load(f)
+        input_value = eval(value.format(**locals()))
+        return input_value
+    
+    def read_json(self,path):
+        with open('config/'+path,encoding='utf-8') as f:
+            data = json.load(f)
+        return data

+ 42 - 0
utils/format_error_data.py

@@ -0,0 +1,42 @@
+import json
+from langchain.chat_models import ChatOpenAI
+from langchain.prompts.chat import (
+    ChatPromptTemplate,
+    SystemMessagePromptTemplate,
+    HumanMessagePromptTemplate,
+)
+from utils.configuration import Configuration
+
+from utils.utils import convert_choice
+
+
+def format_error_data(text):
+    print('[修复]--------------------------修复格式中--------------------------')
+    chat = ChatOpenAI(temperature=0)
+
+    configuration=Configuration()
+    data=configuration.read_json("format_config.json")
+
+    system_template = data["system_template"]
+    system_message_prompt = SystemMessagePromptTemplate.from_template(
+        system_template)
+    human_template = data["human_template"]
+    human_message_prompt = HumanMessagePromptTemplate.from_template(
+        human_template)
+
+    chat_prompt = ChatPromptTemplate.from_messages(
+        [system_message_prompt, human_message_prompt])
+
+    rsp = chat(
+        chat_prompt.format_prompt(text=text).to_messages())
+    print('[修复]--------------------------GPT得到--------------------------')
+    print(rsp.content)
+    try:
+        result = json.loads(rsp.content, object_hook=convert_choice)
+        print(
+        '[修复]--------------------------json.loads得到--------------------------')
+        print(result)
+        return result
+    except:
+        print("修复失败")
+        return None