互动小游戏.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from toolbox import CatchException, update_ui, update_ui_lastest_msg
  2. from crazy_functions.multi_stage.multi_stage_utils import GptAcademicGameBaseState
  3. from crazy_functions.crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
  4. from request_llms.bridge_all import predict_no_ui_long_connection
  5. from crazy_functions.game_fns.game_utils import get_code_block, is_same_thing
  6. @CatchException
  7. def 随机小游戏(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
  8. from crazy_functions.game_fns.game_interactive_story import MiniGame_ResumeStory
  9. # 清空历史
  10. history = []
  11. # 选择游戏
  12. cls = MiniGame_ResumeStory
  13. # 如果之前已经初始化了游戏实例,则继续该实例;否则重新初始化
  14. state = cls.sync_state(chatbot,
  15. llm_kwargs,
  16. cls,
  17. plugin_name='MiniGame_ResumeStory',
  18. callback_fn='crazy_functions.互动小游戏->随机小游戏',
  19. lock_plugin=True
  20. )
  21. yield from state.continue_game(prompt, chatbot, history)
  22. @CatchException
  23. def 随机小游戏1(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
  24. from crazy_functions.game_fns.game_ascii_art import MiniGame_ASCII_Art
  25. # 清空历史
  26. history = []
  27. # 选择游戏
  28. cls = MiniGame_ASCII_Art
  29. # 如果之前已经初始化了游戏实例,则继续该实例;否则重新初始化
  30. state = cls.sync_state(chatbot,
  31. llm_kwargs,
  32. cls,
  33. plugin_name='MiniGame_ASCII_Art',
  34. callback_fn='crazy_functions.互动小游戏->随机小游戏1',
  35. lock_plugin=True
  36. )
  37. yield from state.continue_game(prompt, chatbot, history)