src.prompts.prompt_utils module
Functions for creating and formatting prompts for image and language models.
This module provides utilities to generate prompts for text-to-image models and language models by combining concepts with visual descriptions and formatting generation history.
- src.prompts.prompt_utils.concept_image_prompt(prompt_text: str, concept: str) str[source]
Create an image generation prompt by combining text with visual descriptions.
Combines a base prompt text with a concept and adds random visual descriptions (angles and lighting) to guide the image generation model.
- Parameters:
prompt_text – Base prompt text for the image.
concept – Concept name to include in the prompt.
- Returns:
Complete prompt string for text-to-image generation.
- src.prompts.prompt_utils.generate_prompt(concept_history: Mapping[str, float], generation_history: Sequence[str], prompt_path: str, top_k: int | None = None) str[source]
Generate a prompt for the language model by filling a template.
Creates a formatted prompt by filling a template with the concept history (sorted by score) and generation history. Optionally limits to top-k concepts.
- Parameters:
concept_history – Dictionary mapping concept names to their scores.
generation_history – Sequence of generated concept names.
prompt_path – Path to the prompt template file.
top_k – Optional number of top-scoring concepts to include. If None, includes all concepts.
- Returns:
Formatted prompt string with concept and generation history inserted.