diff --git a/community-contributions/dungeon_extraction_game/game/config.py b/community-contributions/dungeon_extraction_game/game/config.py index 7cf3735..8216c1f 100644 --- a/community-contributions/dungeon_extraction_game/game/config.py +++ b/community-contributions/dungeon_extraction_game/game/config.py @@ -15,7 +15,8 @@ from .storyteller import narrate, set_description_limit load_dotenv(override=True) -# Choose draw function. (Choose one from the imported ones up there) +# Choose draw function. +# Choose one from the imported ones up there or set to None to disable images. DRAW_FUNCTION = draw_dalle_2 # Define a sample scene description for testing purposes. @@ -160,6 +161,7 @@ GAME_CONFIG = Gameplay_Config( scene_style=SCENE_STYLE, scene_prompt=SCENE_PROMPT, storyteller_prompt=STORYTELLER_PROMPT, + disable_img='images/disabled.jpg', error_img='images/machine.jpg', error_narrator='NEURAL SINAPSIS ERROR\n\n{ex}\n\nEND OF LINE\n\nRE-SUBMIT_', error_illustrator='NEURAL PROJECTION ERROR\n\n{ex}\n\nEND OF LINE\n\nRE-SUBMIT_',) diff --git a/community-contributions/dungeon_extraction_game/game/gameplay/gameplay.py b/community-contributions/dungeon_extraction_game/game/gameplay/gameplay.py index 3cc540b..9a95362 100644 --- a/community-contributions/dungeon_extraction_game/game/gameplay/gameplay.py +++ b/community-contributions/dungeon_extraction_game/game/gameplay/gameplay.py @@ -12,6 +12,7 @@ class Gameplay_Config(NamedTuple): scene_style: str scene_prompt: str storyteller_prompt: str + disable_img: str error_img: str error_narrator: str error_illustrator: str @@ -36,18 +37,23 @@ def get_gameplay_function(config: Gameplay_Config): history.append({"role": "user", "content": message}) history.append({"role": "assistant", "content": response.model_dump_json()}) # Draw scene. - _logger.info(f'DRAWING SCENE...') - try: - scene_data = {'scene_description': response.scene_description, - 'scene_style': config.scene_style} - scene_prompt = config.scene_prompt.format(**scene_data) - _logger.info(f'PROMPT BODY IS: \n\n{scene_prompt}\n') - _logger.info(f'PROMPT LENGTH IS: {len(scene_prompt)}') - scene = config.draw_func(scene_prompt) - except Exception as ex: - scene = config.error_img - response = config.error_illustrator.format(ex=ex) - _logger.warning(f'ERROR DRAWING SCENE: {ex}') + if config.draw_func: + _logger.info(f'DRAWING SCENE...') + try: + scene_data = {'scene_description': response.scene_description, + 'scene_style': config.scene_style} + scene_prompt = config.scene_prompt.format(**scene_data) + _logger.info(f'PROMPT BODY IS: \n\n{scene_prompt}\n') + _logger.info(f'PROMPT LENGTH IS: {len(scene_prompt)}') + scene = config.draw_func(scene_prompt) + except Exception as ex: + scene = config.error_img + response = config.error_illustrator.format(ex=ex) + _logger.warning(f'ERROR DRAWING SCENE: {ex}') + return scene, response, history, '' + else: + _logger.info(f'DRAWING DISABLED...') + scene = config.disable_img return scene, response, history, '' return gameplay_function diff --git a/community-contributions/dungeon_extraction_game/images/disabled.jpg b/community-contributions/dungeon_extraction_game/images/disabled.jpg new file mode 100644 index 0000000..2fac5f2 Binary files /dev/null and b/community-contributions/dungeon_extraction_game/images/disabled.jpg differ