浏览代码

Change name, update readme

Shellmiao 2 年之前
父节点
当前提交
7d74212b86

+ 103 - 0
README.md

@@ -0,0 +1,103 @@
+## 
+
+# ImaGetCha
+## 环境配置
+- 安装python=3.9
+
+- 安装python依赖库
+
+  ```powershell
+  pip install -r requirement.txt
+  ```
+
+## 使用
+
+```powershell
+python .\main_module.py
+```
+
+## 配置介绍
+
+通过配置config中的json文件来配置模型结构,下面使用一个例子来介绍如何配置运行结构
+
+### 组件类型
+
+#### Chat
+
+需要配置的属性及其作用(带*的为必填):
+
+1. *class: 标识符,代表完成同类功能,且维护同一输出文件的chat组件
+
+2. *id: 标识符,每个组件在同一class中的标识符,用于区分同class内不同组件
+
+3. input: 输入的数据来源,为{key:value}格式。程序会在运行过程中将value路径对应数据读取,并保存为key=json.load(value)的形式,可在后续过程中被调用
+
+   使用示例( json文件均可用此种方法读取到程序运行过程中 ): 
+
+   ```json
+   "input": {
+       "user_input": "user_input.json",
+       "input_module_prompt":"prompt/input.json",
+       "json_declare":"prompt/json_declare.json"
+   }
+   ```
+
+4. *prompt: 输入chat模型的template模板,结构固定如下
+
+   ```json
+   //prompt/input.json
+   {
+       "system_template": "系统消息,可以在其中加入{占位符},必须填写;会被自动填入prompt中",
+       "human_template": "用户消息,可以在其中加入{占位符},必须填写;会被自动填入prompt中",
+       "其他key": "其他value, 不会被自动当成prompt加入到chat_module中,但可以被当成正常的input读取"
+   }
+   ```
+
+5. prompt_input: 定义输入到prompt中的占位符变量,为{key:value}格式。遵循python语法
+
+   使用示例: 
+
+   1. "style":"user_input['style']":user_input.json(在input属性中定义的user_input对应的json文件)中"style"对应的value。在这里定义后即可在template中使用{style}占位符表示
+   2. "interact":"interact['class_output_data']\[-1\]":module_output/Interact_choose_output.json(在input属性中定义的interact对应的json文件)中"class_output_data"对应的数组的最后一个元素
+   3. "event":"event['class_output_data']\[-4:\]":module_output/GPT_event_output.json(在input属性中定义的event对应的json文件)中"class_output_data"对应的数组的最后四个元素组成的数组
+
+6. *output: 从以下选择填入(目前支持这些,后续再更新)
+
+   1. "{class_output_data}":默认输出到module_output/chat_{classname}_output.json中,并且每次在输出时采取覆盖操作,不保留之前的数据;输出得到的json格式与chat_module输出相同
+
+      ```json
+      {chat_module_output}
+      ```
+
+   2. "{class_output_data_append}":默认输出到module_output/chat_{classname}_output.json中,并且每次在输出时采取添加操作;输出得到的json格式为
+
+      ```json
+      {
+      	"class_output_data": [
+      		...previous_data,{chat_module_output}
+      	]
+      }
+      ```
+
+7. *next_module: 运行此组件完成后的下一个组件,固定格式如下
+
+   ```json
+   "next_module": {
+   	"type": "Chat"/"Judgement"/"Interact",
+       "class": "classname",
+       "id": id
+   }
+   ```
+
+   若无下一个组件,则填入None
+
+   ```json
+   "next_module": None
+   ```
+
+
+
+```json
+
+```
+

+ 0 - 0
config/three_kingdoms_debug/module_output/GPT_event_output.json → config/three_kingdoms_debug/module_output/Ghat_event_output.json


+ 0 - 0
config/three_kingdoms_debug/module_output/GPT_input_output.json → config/three_kingdoms_debug/module_output/Ghat_input_output.json


+ 0 - 0
config/three_kingdoms_debug/module_output/GPT_value_output.json → config/three_kingdoms_debug/module_output/Ghat_value_output.json


+ 22 - 22
config/three_kingdoms_debug/modules_config.json

@@ -1,5 +1,5 @@
 {
-    "GPT": [
+    "Chat": [
         {
             "class": "input",
             "id": 1,
@@ -17,7 +17,7 @@
             "prompt": "prompt/input.json",
             "output": "{class_output_data}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 1
             }
@@ -26,7 +26,7 @@
             "class": "value",
             "id": 1,
             "input": {
-                "intro": "module_output/GPT_input_output.json",
+                "intro": "module_output/Chat_input_output.json",
                 "value_1_module_prompt":"prompt/value_1.json"
             },
             "prompt_input":{
@@ -39,7 +39,7 @@
             "prompt": "prompt/value_1.json",
             "output": "{class_output_data}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 1
             }
@@ -50,8 +50,8 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json"
             },
             "prompt_input":{
@@ -68,7 +68,7 @@
             "prompt": "prompt/event_1.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -77,10 +77,10 @@
             "class": "value",
             "id": 2,
             "input": {
-                "intro": "module_output/GPT_input_output.json",
+                "intro": "module_output/Chat_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"
+                "value": "module_output/Chat_value_output.json",
+                "event": "module_output/Chat_event_output.json"
             },
             "prompt": "prompt/value_2.json",
             "prompt_input":{
@@ -105,10 +105,10 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json",
-                "event": "module_output/GPT_event_output.json",
+                "event": "module_output/Chat_event_output.json",
                 "interact":"module_output/Interact_choose_output.json"
             },
             "prompt_input":{
@@ -127,7 +127,7 @@
             "prompt": "prompt/event_2.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -138,10 +138,10 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json",
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "prompt_input":{
                 "style":"user_input['style']",
@@ -158,7 +158,7 @@
             "prompt": "prompt/event_2.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -169,7 +169,7 @@
             "class": "Boolean",
             "id": 1,
             "input": {
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "value":"event['class_output_data'][-1]['是否需要玩家选择下一步操作']",
             "if_true_next": {
@@ -178,7 +178,7 @@
                 "id": 1
             },
             "if_false_next": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 3
             }
@@ -189,12 +189,12 @@
             "class": "choose",
             "id": 1,
             "input": {
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 2
             }

+ 0 - 0
config/three_kingdoms_product/module_output/GPT_event_output.json → config/three_kingdoms_product/module_output/Ghat_event_output.json


+ 0 - 0
config/three_kingdoms_product/module_output/GPT_input_output.json → config/three_kingdoms_product/module_output/Ghat_input_output.json


+ 0 - 0
config/three_kingdoms_product/module_output/GPT_value_output.json → config/three_kingdoms_product/module_output/Ghat_value_output.json


+ 25 - 25
config/three_kingdoms_product/modules_config.json

@@ -1,5 +1,5 @@
 {
-    "GPT": [
+    "Chat": [
         {
             "class": "input",
             "id": 1,
@@ -17,7 +17,7 @@
             "prompt": "prompt/input.json",
             "output": "{class_output_data}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 1
             }
@@ -26,7 +26,7 @@
             "class": "value",
             "id": 1,
             "input": {
-                "intro": "module_output/GPT_input_output.json",
+                "intro": "module_output/Chat_input_output.json",
                 "value_1_module_prompt":"prompt/value_1.json"
             },
             "prompt_input":{
@@ -39,7 +39,7 @@
             "prompt": "prompt/value_1.json",
             "output": "{class_output_data}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 1
             }
@@ -50,8 +50,8 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json"
             },
             "prompt_input":{
@@ -68,7 +68,7 @@
             "prompt": "prompt/event_1.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -77,10 +77,10 @@
             "class": "value",
             "id": 2,
             "input": {
-                "intro": "module_output/GPT_input_output.json",
+                "intro": "module_output/Chat_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"
+                "value": "module_output/Chat_value_output.json",
+                "event": "module_output/Chat_event_output.json"
             },
             "prompt": "prompt/value_2.json",
             "prompt_input":{
@@ -88,7 +88,7 @@
                 "npc":"intro['角色设定']",
                 "value_system":"intro['数值系统']",
                 "target":"intro['游戏通关所需条件']",
-                "event":"event['class_output_data']",
+                "event":"event['class_output_data'][-4:]",
                 "value":"value['value']",
                 "output_type":"value_1_module_prompt['output_type']"
             },
@@ -105,10 +105,10 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json",
-                "event": "module_output/GPT_event_output.json",
+                "event": "module_output/Chat_event_output.json",
                 "interact":"module_output/Interact_choose_output.json"
             },
             "prompt_input":{
@@ -121,13 +121,13 @@
                 "output_type":"event_module_prompt['output_type']",
                 "json_declare":"json_declare['json_declare']",
                 "value":"value['value']",
-                "event":"event['class_output_data'][-3:]",
+                "event":"event['class_output_data'][-4:]",
                 "interact":"interact['class_output_data'][-1]"
             },
             "prompt": "prompt/event_2.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -138,10 +138,10 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json",
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "prompt_input":{
                 "style":"user_input['style']",
@@ -153,12 +153,12 @@
                 "output_type":"event_module_prompt['output_type']",
                 "json_declare":"json_declare['json_declare']",
                 "value":"value['value']",
-                "event":"event['class_output_data'][-3:]"
+                "event":"event['class_output_data'][-4:]"
             },
             "prompt": "prompt/event_3.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -169,7 +169,7 @@
             "class": "Boolean",
             "id": 1,
             "input": {
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "value":"event['class_output_data'][-1]['是否需要玩家选择下一步操作']",
             "if_true_next": {
@@ -178,7 +178,7 @@
                 "id": 1
             },
             "if_false_next": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 3
             }
@@ -189,12 +189,12 @@
             "class": "choose",
             "id": 1,
             "input": {
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 2
             }

+ 0 - 0
config/three_kingdoms_test/module_output/GPT_event_output.json → config/three_kingdoms_test/module_output/Ghat_event_output.json


+ 0 - 0
config/three_kingdoms_test/module_output/GPT_input_output.json → config/three_kingdoms_test/module_output/Ghat_input_output.json


+ 0 - 0
config/three_kingdoms_test/module_output/GPT_value_output.json → config/three_kingdoms_test/module_output/Ghat_value_output.json


+ 22 - 22
config/three_kingdoms_test/modules_config.json

@@ -1,5 +1,5 @@
 {
-    "GPT": [
+    "Chat": [
         {
             "class": "input",
             "id": 1,
@@ -17,7 +17,7 @@
             "prompt": "prompt/input.json",
             "output": "{class_output_data}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 1
             }
@@ -26,7 +26,7 @@
             "class": "value",
             "id": 1,
             "input": {
-                "intro": "module_output/GPT_input_output.json",
+                "intro": "module_output/Chat_input_output.json",
                 "value_1_module_prompt":"prompt/value_1.json"
             },
             "prompt_input":{
@@ -39,7 +39,7 @@
             "prompt": "prompt/value_1.json",
             "output": "{class_output_data}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 1
             }
@@ -50,8 +50,8 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json"
             },
             "prompt_input":{
@@ -68,7 +68,7 @@
             "prompt": "prompt/event_1.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -77,10 +77,10 @@
             "class": "value",
             "id": 2,
             "input": {
-                "intro": "module_output/GPT_input_output.json",
+                "intro": "module_output/Chat_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"
+                "value": "module_output/Chat_value_output.json",
+                "event": "module_output/Chat_event_output.json"
             },
             "prompt": "prompt/value_2.json",
             "prompt_input":{
@@ -105,10 +105,10 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json",
-                "event": "module_output/GPT_event_output.json",
+                "event": "module_output/Chat_event_output.json",
                 "interact":"module_output/Interact_choose_output.json"
             },
             "prompt_input":{
@@ -127,7 +127,7 @@
             "prompt": "prompt/event_2.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -138,10 +138,10 @@
             "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",
+                "intro": "module_output/Chat_input_output.json",
+                "value": "module_output/Chat_value_output.json",
                 "json_declare":"prompt/json_declare.json",
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "prompt_input":{
                 "style":"user_input['style']",
@@ -158,7 +158,7 @@
             "prompt": "prompt/event_3.json",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "value",
                 "id": 2
             }
@@ -169,7 +169,7 @@
             "class": "Boolean",
             "id": 1,
             "input": {
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "value":"event['class_output_data'][-1]['是否需要玩家选择下一步操作']",
             "if_true_next": {
@@ -178,7 +178,7 @@
                 "id": 1
             },
             "if_false_next": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 3
             }
@@ -189,12 +189,12 @@
             "class": "choose",
             "id": 1,
             "input": {
-                "event": "module_output/GPT_event_output.json"
+                "event": "module_output/Chat_event_output.json"
             },
             "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
             "output": "{class_output_data_append}",
             "next_module": {
-                "type": "GPT",
+                "type": "Chat",
                 "class": "event",
                 "id": 2
             }

+ 34 - 51
main_module.py

@@ -1,20 +1,43 @@
 from modules.conditional_judgement_module import judgment_module
-from modules.gpt_module import gpt_module
+from modules.chat_module import chat_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)
+import argparse
+
+parser = argparse.ArgumentParser(description="生成文字游戏")
+parser.add_argument("-n",
+                    "--name",
+                    required=True,
+                    help="config文件夹中配置的文件夹名称")
+parser.add_argument("-t",
+                    "--type",
+                    required=True,
+                    help="开始的第一个组件的类型")
+parser.add_argument("-c",
+                    "--classname",
+                    required=True,
+                    help="开始的第一个组件的classname")
+parser.add_argument("-i",
+                    "--id",
+                    required=True,
+                    help="开始的第一个组件的id")
+
+args = parser.parse_args()
+
+next_module = {
+    "type": args.type,
+    "class": args.classname,
+    "id": args.id
+}
+
+configuration=Configuration(args.name)
 
 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"])
+    if next_module["type"]=="Chat":
+        input_path,prompt_input_declare,prompt_path,output,next_module_temp=configuration.read_chat_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)
+        chat_module(next_module["class"],next_module["id"],prompt_input_value,prompt,output)
         next_module=next_module_temp
 
     elif next_module["type"]=="Judgement":
@@ -27,44 +50,4 @@ while True:
         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)
-
+        break

+ 4 - 4
modules/gpt_module.py → modules/chat_module.py

@@ -11,8 +11,8 @@ 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--------------------------')
+def chat_module(classname,id,input,prompt,output):
+    print('--------------------------Chat--------------------------')
     chat = ChatOpenAI(temperature=0)
 
     system_template = prompt["system_template"]
@@ -33,7 +33,7 @@ def gpt_module(classname,id,input,prompt,output):
         print(game_event)
         save_2_json(classname,id,output,game_event)
     except:
-        print('JSON格式解析错误,GPT输出如下,尝试修复')
+        print('JSON格式解析错误,Chat输出如下,尝试修复')
         print(rsp.content)
         game_event=format_error_data(rsp.content)
         if game_event is not None:
@@ -41,5 +41,5 @@ def gpt_module(classname,id,input,prompt,output):
 
 def save_2_json(classname,id,output_type,data):
     configuration=Configuration()
-    file_path="GPT_"+classname+"_output.json"
+    file_path="Chat_"+classname+"_output.json"
     configuration.save_2_json(file_path,output_type,data)

+ 5 - 5
utils/configuration.py

@@ -59,13 +59,13 @@ class Configuration:
             prompt = json.load(f)
         return prompt
 
-    def read_gpt_config(self,classname,id):
+    def read_chat_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"]
+        chats=data["Chat"]
+        for chat in chats:
+            if chat["id"]==id and chat["class"]==classname:
+                return chat["input"],chat["prompt_input"],chat["prompt"],chat["output"],chat["next_module"]
             
     def read_judgement_config(self,classname,id):
         with open('config/'+self.game_name+'/modules_config.json',encoding='utf-8') as f:

+ 1 - 1
utils/format_error_data.py

@@ -29,7 +29,7 @@ def format_error_data(text):
 
     rsp = chat(
         chat_prompt.format_prompt(text=text).to_messages())
-    print('[修复]--------------------------GPT得到--------------------------')
+    print('[修复]--------------------------Chat得到--------------------------')
     print(rsp.content)
     try:
         result = json.loads(rsp.content, object_hook=convert_choice)