main_module.py 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from modules.conditional_judgement_module import judgment_module
  2. from modules.gpt_module import gpt_module
  3. from modules.interact_module import interact_module
  4. from utils.configuration import Configuration
  5. configuration=Configuration('three_kingdoms_test')
  6. input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('input',1)
  7. prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  8. prompt=configuration.read_prompt(prompt_path)
  9. gpt_module('input',1,prompt_input_value,prompt,output)
  10. while True:
  11. if next_module["type"]=="GPT":
  12. input_path,prompt_input_declare,prompt_path,output,next_module_temp=configuration.read_gpt_config(next_module["class"],next_module["id"])
  13. prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  14. prompt=configuration.read_prompt(prompt_path)
  15. gpt_module(next_module["class"],next_module["id"],prompt_input_value,prompt,output)
  16. next_module=next_module_temp
  17. elif next_module["type"]=="Judgement":
  18. input,value,judgement=configuration.read_judgement_config(next_module["class"],next_module["id"])
  19. input_value=configuration.judgement_input_process(input,value)
  20. next_module=judgment_module(next_module["class"],input_value,judgement)
  21. elif next_module["type"]=="Interact":
  22. input,choices,output,next_module_temp=configuration.read_interact_config(next_module["class"],next_module["id"])
  23. choices_value=configuration.interact_input_process(input,choices)
  24. interact_module(next_module["class"],next_module["id"],choices_value,output)
  25. next_module=next_module_temp
  26. else:
  27. break
  28. # input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('input',1)
  29. # prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  30. # prompt=configuration.read_prompt(prompt_path)
  31. # gpt_module('input',1,prompt_input_value,prompt,output)
  32. # input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('value',1)
  33. # prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  34. # prompt=configuration.read_prompt(prompt_path)
  35. # gpt_module('value',1,prompt_input_value,prompt,output)
  36. # input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('event',1)
  37. # prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  38. # prompt=configuration.read_prompt(prompt_path)
  39. # gpt_module('event',1,prompt_input_value,prompt,output)
  40. # input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('value',2)
  41. # prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  42. # prompt=configuration.read_prompt(prompt_path)
  43. # gpt_module('value',2,prompt_input_value,prompt,output)
  44. # input,value,judgement=configuration.read_judgement_config('Boolean',1)
  45. # input_value=configuration.judgement_input_process(input,value)
  46. # result=judgment_module('Boolean',input_value,judgement)
  47. # if result["type"]=="Interact":
  48. # input,choices,output=configuration.read_interact_config(result["class"],result["id"])
  49. # choices_value=configuration.interact_input_process(input,choices)
  50. # interact_module(result["class"],result["id"],choices_value,output)
  51. # input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('event',2)
  52. # prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  53. # prompt=configuration.read_prompt(prompt_path)
  54. # gpt_module('event',2,prompt_input_value,prompt,output)
  55. # input_path,prompt_input_declare,prompt_path,output,next_module=configuration.read_gpt_config('value',2)
  56. # prompt_input_value=configuration.prompt_input_process(input_path,prompt_input_declare)
  57. # prompt=configuration.read_prompt(prompt_path)
  58. # gpt_module('value',2,prompt_input_value,prompt,output)