Allow disabling images by config

This commit is contained in:
Carlos Bazaga
2025-09-05 22:51:02 +02:00
parent 9c301f8bee
commit 97967e33e9
3 changed files with 21 additions and 13 deletions

View File

@@ -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_',)

View File

@@ -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,6 +37,7 @@ def get_gameplay_function(config: Gameplay_Config):
history.append({"role": "user", "content": message})
history.append({"role": "assistant", "content": response.model_dump_json()})
# Draw scene.
if config.draw_func:
_logger.info(f'DRAWING SCENE...')
try:
scene_data = {'scene_description': response.scene_description,
@@ -49,6 +51,10 @@ def get_gameplay_function(config: Gameplay_Config):
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 KiB