Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Reorganize backend prompt structure

Abi Raja29ccd8067edc
diff --git a/backend/evals/core.py b/backend/evals/core.py
index ea57a395..d687498e 100644
--- a/backend/evals/core.py
+++ b/backend/evals/core.py
@@ -6,14 +6,14 @@ from config import (
)
from llm import Llm, OPENAI_MODELS, ANTHROPIC_MODELS, GEMINI_MODELS
from agent.runner import AgenticRunner
-from prompts import assemble_prompt
-from prompts.types import Stack
+from prompts.builders import build_image_prompt_messages
+from prompts.prompt_types import Stack
from openai.types.chat import ChatCompletionMessageParam
from typing import Any
async def generate_code_for_image(image_url: str, stack: Stack, model: Llm) -> str:
- prompt_messages = assemble_prompt([image_url], stack)
+ prompt_messages = build_image_prompt_messages([image_url], stack)
async def send_message(
_: str,
__: str | None,
diff --git a/backend/evals/runner.py b/backend/evals/runner.py
index 3ea542e5..46d27d89 100644
--- a/backend/evals/runner.py
+++ b/backend/evals/runner.py
@@ -4,7 +4,7 @@ import os
from datetime import datetime
import time
from llm import Llm
-from prompts.types import Stack
+from prompts.prompt_types import Stack
from .core import generate_code_for_image
from .utils import image_to_data_url
from .config import EVALS_DIR
diff --git a/backend/prompts/__init__.py b/backend/prompts/__init__.py
index 6c72b83e..073447c0 100644
--- a/backend/prompts/__init__.py
+++ b/backend/prompts/__init__.py
@@ -1,311 +1,7 @@
-from typing import Any, cast
-from openai.types.chat import ChatCompletionMessageParam, ChatCompletionContentPartParam
-
-from custom_types import InputMode
-from prompts.screenshot_system_prompts import SYSTEM_PROMPT
+from prompts.system_prompt import SYSTEM_PROMPT
from prompts.video_prompts import GEMINI_VIDEO_PROMPT
-from prompts.types import Stack, PromptContent
-
-
-USER_PROMPT = """
-Generate code for a web page that looks exactly like the provided screenshot(s).
-If multiple screenshots are provided, organize them meaningfully. If they appear to be
-different pages in a website, make them distinct pages and link them. If they look like
-different tabs or views in an app, connect them with appropriate navigation. If they
-appear unrelated, create a scaffold that separates them into "Screenshot 1", "Screenshot 2",
-"Screenshot 3", etc. so it is easy to navigate.
-For mobile screenshots, do not include the device frame or browser chrome; focus only on
-the actual UI mockups.
-"""
-
-IMPORTED_CODE_INSTRUCTIONS = """
-You are continuing from an imported codebase. Follow these instructions while updating it:
-
-- Do not add comments in the code such as "<!-- Add other navigation links as needed -->" or "<!-- ... other news items ... -->" in place of writing the full code. WRITE THE FULL CODE.
-- Repeat elements as needed. For example, if there are 15 items, the code should have 15 items. DO NOT LEAVE comments like "<!-- Repeat for each news item -->" or bad things will happen.
-- For images, use placeholder images from https://placehold.co and include a detailed description of the image in the alt text so that an image generation AI can generate the image later.
-"""
-
-
-async def create_prompt(
- stack: Stack,
- input_mode: InputMode,
- generation_type: str,
- prompt: PromptContent,
- history: list[dict[str, Any]],
- is_imported_from_code: bool,
-) -> list[ChatCompletionMessageParam]:
-
- prompt_messages: list[ChatCompletionMessageParam] = []
-
- # If this generation started off with imported code, we need to assemble the prompt differently
- if is_imported_from_code:
- original_imported_code = history[0]["text"] if history else ""
- imported_user_prompt = get_imported_code_user_prompt(prompt, history)
- prompt_messages = assemble_imported_code_prompt(
- original_imported_code,
- stack,
- imported_user_prompt,
- )
- else:
- # Assemble the prompt for non-imported code
- if input_mode == "image":
- image_urls = prompt.get("images", [])
- text_prompt = prompt.get("text", "")
- prompt_messages = assemble_prompt(image_urls, stack, text_prompt)
- elif input_mode == "text":
- prompt_messages = assemble_text_prompt(prompt["text"], stack)
- elif input_mode == "video":
- if generation_type == "create":
- video_urls = prompt.get("images", [])
- if not video_urls:
- raise ValueError("Video mode requires a video to be provided")
- video_url = video_urls[0]
- prompt_messages = assemble_video_prompt(
- video_data_url=video_url,
- text_prompt=prompt.get("text", ""),
- )
- else:
- # For video mode updates, use the screenshot system prompt
- # since we're now working with the generated code, not the video
- prompt_messages = [
- cast(
- ChatCompletionMessageParam,
- {
- "role": "system",
- "content": SYSTEM_PROMPT,
- },
- )
- ]
- else:
- # Default to image mode for backward compatibility
- image_urls = prompt.get("images", [])
- text_prompt = prompt.get("text", "")
- prompt_messages = assemble_prompt(image_urls, stack, text_prompt)
-
- if generation_type == "update":
- # Transform the history tree into message format
- for index, item in enumerate(history):
- role = "assistant" if index % 2 == 0 else "user"
- message = create_message_from_history_item(item, role)
- prompt_messages.append(message)
-
- return prompt_messages
-
-
-def create_message_from_history_item(
- item: dict[str, Any], role: str
-) -> ChatCompletionMessageParam:
- """
- Create a ChatCompletionMessageParam from a history item.
- Handles both text-only and text+images content.
- """
- # Check if this is a user message with images
- if role == "user" and item.get("images") and len(item["images"]) > 0:
- # Create multipart content for user messages with images
- user_content: list[ChatCompletionContentPartParam] = []
-
- # Add all images first
- for image_url in item["images"]:
- user_content.append(
- {
- "type": "image_url",
- "image_url": {"url": image_url, "detail": "high"},
- }
- )
-
- # Add text content
- user_content.append(
- {
- "type": "text",
- "text": item["text"],
- }
- )
-
- return cast(
- ChatCompletionMessageParam,
- {
- "role": role,
- "content": user_content,
- },
- )
- else:
- # Regular text-only message
- return cast(
- ChatCompletionMessageParam,
- {
- "role": role,
- "content": item["text"],
- },
- )
-
-
-def assemble_imported_code_prompt(
- code: str,
- stack: Stack,
- user_prompt: PromptContent,
-) -> list[ChatCompletionMessageParam]:
- system_content = (
- SYSTEM_PROMPT.strip()
- + "\n\n"
- + IMPORTED_CODE_INSTRUCTIONS.strip()
- + f"\n\nSelected stack: {stack}."
- + "\n\nThe current app code is provided below. Update it per the request."
- + f"\n\n{code}"
- )
-
- return [
- {
- "role": "system",
- "content": system_content,
- },
- create_message_from_history_item(
- {
- "text": user_prompt.get("text", ""),
- "images": user_prompt.get("images", []),
- },
- "user",
- ),
- ]
-
-
-def get_imported_code_user_prompt(
- prompt: PromptContent,
- history: list[dict[str, Any]],
-) -> PromptContent:
- prompt_text = prompt.get("text", "")
- prompt_images = prompt.get("images", [])
- normalized_prompt_images: list[str] = []
- if isinstance(prompt_images, list):
- raw_prompt_images = cast(list[object], prompt_images)
- for image in raw_prompt_images:
- if isinstance(image, str):
- normalized_prompt_images.append(image)
-
- # Preferred path: if prompt has text, treat it as the latest user instruction.
- if prompt_text.strip():
- return {
- "text": prompt_text,
- "images": normalized_prompt_images,
- }
-
- # Backward-compatibility path: recover latest user turn from imported-code history.
- for index in range(len(history) - 1, 0, -1):
- if index % 2 == 1:
- item = history[index]
- text = item.get("text", "")
- images = item.get("images", [])
- normalized_images: list[str] = []
- if isinstance(images, list):
- raw_images = cast(list[object], images)
- for image in raw_images:
- if isinstance(image, str):
- normalized_images.append(image)
- return {
- "text": text if isinstance(text, str) else "",
- "images": normalized_images,
- }
-
- # Final fallback: if prompt only has images, keep them so visual references are not lost.
- if normalized_prompt_images:
- return {
- "text": "",
- "images": normalized_prompt_images,
- }
-
- return {
- "text": "Update the imported code according to the latest request.",
- "images": [],
- }
-
-
-def assemble_prompt(
- image_data_urls: list[str],
- stack: Stack,
- text_prompt: str = "",
-) -> list[ChatCompletionMessageParam]:
- system_content = SYSTEM_PROMPT
- user_prompt = USER_PROMPT.strip() + f"\n\nSelected stack: {stack}"
-
- # Append optional text instructions if provided
- if text_prompt.strip():
- user_prompt = user_prompt + "\n\nAdditional instructions: " + text_prompt
-
- user_content: list[ChatCompletionContentPartParam] = []
- for image_data_url in image_data_urls:
- user_content.append(
- {
- "type": "image_url",
- "image_url": {"url": image_data_url, "detail": "high"},
- }
- )
- user_content.append(
- {
- "type": "text",
- "text": user_prompt,
- }
- )
- return [
- {
- "role": "system",
- "content": system_content,
- },
- {
- "role": "user",
- "content": user_content,
- },
- ]
-
-
-def assemble_text_prompt(
- text_prompt: str,
- stack: Stack,
-) -> list[ChatCompletionMessageParam]:
-
- return [
- {
- "role": "system",
- "content": SYSTEM_PROMPT,
- },
- {
- "role": "user",
- "content": f"""
- - Make sure to make it look modern and sleek.
- - Use modern, professional fonts and colors.
- - Follow UX best practices.
- Selected stack: {stack}.
- Generate UI for {text_prompt}.
- """,
- },
- ]
-
-
-def assemble_video_prompt(
- video_data_url: str,
- text_prompt: str = "",
-) -> list[ChatCompletionMessageParam]:
- user_text = "Analyze this video and generate the code."
- if text_prompt.strip():
- user_text = user_text + "\n\nAdditional instructions: " + text_prompt
-
- user_content: list[ChatCompletionContentPartParam] = [
- {
- "type": "image_url",
- "image_url": {"url": video_data_url, "detail": "high"},
- },
- {
- "type": "text",
- "text": user_text,
- },
- ]
- return [
- {
- "role": "system",
- "content": GEMINI_VIDEO_PROMPT,
- },
- {
- "role": "user",
- "content": user_content,
- },
- ]
+__all__ = [
+ "SYSTEM_PROMPT",
+ "GEMINI_VIDEO_PROMPT",
+]
diff --git a/backend/prompts/builders.py b/backend/prompts/builders.py
new file mode 100644
index 00000000..002e331a
--- /dev/null
+++ b/backend/prompts/builders.py
@@ -0,0 +1,288 @@
+from typing import Any, cast
+
+from openai.types.chat import ChatCompletionContentPartParam, ChatCompletionMessageParam
+
+from custom_types import InputMode
+from prompts.prompt_types import PromptContent, Stack
+from prompts.system_prompt import SYSTEM_PROMPT
+from prompts.video_prompts import GEMINI_VIDEO_PROMPT
+
+
+USER_PROMPT = """
+Generate code for a web page that looks exactly like the provided screenshot(s).
+If multiple screenshots are provided, organize them meaningfully. If they appear to be
+different pages in a website, make them distinct pages and link them. If they look like
+different tabs or views in an app, connect them with appropriate navigation. If they
+appear unrelated, create a scaffold that separates them into "Screenshot 1", "Screenshot 2",
+"Screenshot 3", etc. so it is easy to navigate.
+For mobile screenshots, do not include the device frame or browser chrome; focus only on
+the actual UI mockups.
+"""
+
+IMPORTED_CODE_INSTRUCTIONS = """
+You are continuing from an imported codebase. Follow these instructions while updating it:
+
+- Do not add comments in the code such as "<!-- Add other navigation links as needed -->" or "<!-- ... other news items ... -->" in place of writing the full code. WRITE THE FULL CODE.
+- Repeat elements as needed. For example, if there are 15 items, the code should have 15 items. DO NOT LEAVE comments like "<!-- Repeat for each news item -->" or bad things will happen.
+- For images, use placeholder images from https://placehold.co and include a detailed description of the image in the alt text so that an image generation AI can generate the image later.
+"""
+
+
+async def build_prompt_messages(
+ stack: Stack,
+ input_mode: InputMode,
+ generation_type: str,
+ prompt: PromptContent,
+ history: list[dict[str, Any]],
+ is_imported_from_code: bool,
+) -> list[ChatCompletionMessageParam]:
+ prompt_messages: list[ChatCompletionMessageParam] = []
+
+ if is_imported_from_code:
+ original_imported_code = history[0]["text"] if history else ""
+ imported_user_prompt = resolve_imported_code_user_prompt(prompt, history)
+ prompt_messages = build_imported_code_prompt_messages(
+ original_imported_code,
+ stack,
+ imported_user_prompt,
+ )
+ else:
+ if input_mode == "image":
+ image_urls = prompt.get("images", [])
+ text_prompt = prompt.get("text", "")
+ prompt_messages = build_image_prompt_messages(image_urls, stack, text_prompt)
+ elif input_mode == "text":
+ prompt_messages = build_text_prompt_messages(prompt["text"], stack)
+ elif input_mode == "video":
+ if generation_type == "create":
+ video_urls = prompt.get("images", [])
+ if not video_urls:
+ raise ValueError("Video mode requires a video to be provided")
+ video_url = video_urls[0]
+ prompt_messages = build_video_prompt_messages(
+ video_data_url=video_url,
+ text_prompt=prompt.get("text", ""),
+ )
+ else:
+ prompt_messages = [
+ cast(
+ ChatCompletionMessageParam,
+ {"role": "system", "content": SYSTEM_PROMPT},
+ )
+ ]
+ else:
+ image_urls = prompt.get("images", [])
+ text_prompt = prompt.get("text", "")
+ prompt_messages = build_image_prompt_messages(image_urls, stack, text_prompt)
+
+ if generation_type == "update":
+ for index, item in enumerate(history):
+ role = "assistant" if index % 2 == 0 else "user"
+ message = build_history_message(item, role)
+ prompt_messages.append(message)
+
+ return prompt_messages
+
+
+def build_history_message(
+ item: dict[str, Any], role: str
+) -> ChatCompletionMessageParam:
+ if role == "user" and item.get("images") and len(item["images"]) > 0:
+ user_content: list[ChatCompletionContentPartParam] = []
+
+ for image_url in item["images"]:
+ user_content.append(
+ {
+ "type": "image_url",
+ "image_url": {"url": image_url, "detail": "high"},
+ }
+ )
+
+ user_content.append(
+ {
+ "type": "text",
+ "text": item["text"],
+ }
+ )
+
+ return cast(
+ ChatCompletionMessageParam,
+ {
+ "role": role,
+ "content": user_content,
+ },
+ )
+
+ return cast(
+ ChatCompletionMessageParam,
+ {
+ "role": role,
+ "content": item["text"],
+ },
+ )
+
+
+def build_imported_code_prompt_messages(
+ code: str,
+ stack: Stack,
+ user_prompt: PromptContent,
+) -> list[ChatCompletionMessageParam]:
+ system_content = (
+ SYSTEM_PROMPT.strip()
+ + "\n\n"
+ + IMPORTED_CODE_INSTRUCTIONS.strip()
+ + f"\n\nSelected stack: {stack}."
+ + "\n\nThe current app code is provided below. Update it per the request."
+ + f"\n\n{code}"
+ )
+
+ return [
+ {
+ "role": "system",
+ "content": system_content,
+ },
+ build_history_message(
+ {
+ "text": user_prompt.get("text", ""),
+ "images": user_prompt.get("images", []),
+ },
+ "user",
+ ),
+ ]
+
+
+def resolve_imported_code_user_prompt(
+ prompt: PromptContent,
+ history: list[dict[str, Any]],
+) -> PromptContent:
+ prompt_text = prompt.get("text", "")
+ prompt_images = prompt.get("images", [])
+ normalized_prompt_images: list[str] = []
+ if isinstance(prompt_images, list):
+ raw_prompt_images = cast(list[object], prompt_images)
+ for image in raw_prompt_images:
+ if isinstance(image, str):
+ normalized_prompt_images.append(image)
+
+ if prompt_text.strip():
+ return {
+ "text": prompt_text,
+ "images": normalized_prompt_images,
+ }
+
+ for index in range(len(history) - 1, 0, -1):
+ if index % 2 == 1:
+ item = history[index]
+ text = item.get("text", "")
+ images = item.get("images", [])
+ normalized_images: list[str] = []
+ if isinstance(images, list):
+ raw_images = cast(list[object], images)
+ for image in raw_images:
+ if isinstance(image, str):
+ normalized_images.append(image)
+ return {
+ "text": text if isinstance(text, str) else "",
+ "images": normalized_images,
+ }
+
+ if normalized_prompt_images:
+ return {
+ "text": "",
+ "images": normalized_prompt_images,
+ }
+
+ return {
+ "text": "Update the imported code according to the latest request.",
+ "images": [],
+ }
+
+
+def build_image_prompt_messages(
+ image_data_urls: list[str],
+ stack: Stack,
+ text_prompt: str = "",
+) -> list[ChatCompletionMessageParam]:
+ system_content = SYSTEM_PROMPT
+ user_prompt = USER_PROMPT.strip() + f"\n\nSelected stack: {stack}"
+
+ if text_prompt.strip():
+ user_prompt = user_prompt + "\n\nAdditional instructions: " + text_prompt
+
+ user_content: list[ChatCompletionContentPartParam] = []
+ for image_data_url in image_data_urls:
+ user_content.append(
+ {
+ "type": "image_url",
+ "image_url": {"url": image_data_url, "detail": "high"},
+ }
+ )
+ user_content.append(
+ {
+ "type": "text",
+ "text": user_prompt,
+ }
+ )
+ return [
+ {
+ "role": "system",
+ "content": system_content,
+ },
+ {
+ "role": "user",
+ "content": user_content,
+ },
+ ]
+
+
+def build_text_prompt_messages(
+ text_prompt: str,
+ stack: Stack,
+) -> list[ChatCompletionMessageParam]:
+ return [
+ {
+ "role": "system",
+ "content": SYSTEM_PROMPT,
+ },
+ {
+ "role": "user",
+ "content": f"""
+ - Make sure to make it look modern and sleek.
+ - Use modern, professional fonts and colors.
+ - Follow UX best practices.
+ Selected stack: {stack}.
+ Generate UI for {text_prompt}.
+ """,
+ },
+ ]
+
+
+def build_video_prompt_messages(
+ video_data_url: str,
+ text_prompt: str = "",
+) -> list[ChatCompletionMessageParam]:
+ user_text = "Analyze this video and generate the code."
+ if text_prompt.strip():
+ user_text = user_text + "\n\nAdditional instructions: " + text_prompt
+
+ user_content: list[ChatCompletionContentPartParam] = [
+ {
+ "type": "image_url",
+ "image_url": {"url": video_data_url, "detail": "high"},
+ },
+ {
+ "type": "text",
+ "text": user_text,
+ },
+ ]
+
+ return [
+ {
+ "role": "system",
+ "content": GEMINI_VIDEO_PROMPT,
+ },
+ {
+ "role": "user",
+ "content": user_content,
+ },
+ ]
diff --git a/backend/prompts/types.py b/backend/prompts/prompt_types.py
similarity index 65%
rename from backend/prompts/types.py
rename to backend/prompts/prompt_types.py
index e1361d07..fad9456a 100644
--- a/backend/prompts/types.py
+++ b/backend/prompts/prompt_types.py
@@ -1,15 +1,6 @@
from typing import Literal, TypedDict, List
-class SystemPrompts(TypedDict):
- html_css: str
- html_tailwind: str
- react_tailwind: str
- bootstrap: str
- ionic_tailwind: str
- vue_tailwind: str
-
-
class PromptContent(TypedDict):
"""Unified structure for prompt text and images."""
diff --git a/backend/prompts/screenshot_system_prompts.py b/backend/prompts/system_prompt.py
similarity index 100%
rename from backend/prompts/screenshot_system_prompts.py
rename to backend/prompts/system_prompt.py
diff --git a/backend/routes/evals.py b/backend/routes/evals.py
index e7523af0..af8f61f9 100644
--- a/backend/routes/evals.py
+++ b/backend/routes/evals.py
@@ -7,7 +7,7 @@ from typing import Set
from evals.runner import run_image_evals
from typing import List, Dict
from llm import Llm
-from prompts.types import Stack
+from prompts.prompt_types import Stack
from pathlib import Path
router = APIRouter()
@@ -197,7 +197,7 @@ async def run_evals(request: RunEvalsRequest) -> List[str]:
async def get_models():
current_models = [model.value for model in Llm]
- # Import Stack type from prompts.types and get all literal values
+ # Import Stack type from prompts.prompt_types and get all literal values
available_stacks = list(Stack.__args__)
return {"models": current_models, "stacks": available_stacks}
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index e5be34c8..9a8450e3 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -53,8 +53,8 @@ MessageType = Literal[
"toolStart",
"toolResult",
]
-from prompts import create_prompt
-from prompts.types import Stack, PromptContent
+from prompts.builders import build_prompt_messages
+from prompts.prompt_types import Stack, PromptContent
from agent.runner import AgenticRunner
# from utils import pprint_prompt
@@ -472,13 +472,13 @@ class PromptCreationStage:
def __init__(self, throw_error: Callable[[str], Coroutine[Any, Any, None]]):
self.throw_error = throw_error
- async def create_prompt(
+ async def build_prompt_messages(
self,
extracted_params: ExtractedParams,
) -> List[ChatCompletionMessageParam]:
"""Create prompt messages"""
try:
- prompt_messages = await create_prompt(
+ prompt_messages = await build_prompt_messages(
stack=extracted_params.stack,
input_mode=extracted_params.input_mode,
generation_type=extracted_params.generation_type,
@@ -774,7 +774,7 @@ class PromptCreationMiddleware(Middleware):
) -> None:
prompt_creator = PromptCreationStage(context.throw_error)
assert context.extracted_params is not None
- context.prompt_messages = await prompt_creator.create_prompt(
+ context.prompt_messages = await prompt_creator.build_prompt_messages(
context.extracted_params,
)
await next_func()
diff --git a/backend/tests/test_prompts.py b/backend/tests/test_prompts.py
index f2a6b43a..3e177367 100644
--- a/backend/tests/test_prompts.py
+++ b/backend/tests/test_prompts.py
@@ -8,8 +8,8 @@ from openai.types.chat import ChatCompletionMessageParam
sys.modules["moviepy"] = MagicMock()
sys.modules["moviepy.editor"] = MagicMock()
-from prompts import create_prompt
-from prompts.types import Stack
+from prompts.builders import build_prompt_messages
+from prompts.prompt_types import Stack
# Type definitions for test structures
class ExpectedResult(TypedDict):
@@ -91,9 +91,9 @@ class TestCreatePrompt:
"generationType": "create",
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -145,9 +145,9 @@ class TestCreatePrompt:
],
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -199,9 +199,9 @@ class TestCreatePrompt:
},
"generationType": "create"
}
- with patch('prompts.SYSTEM_PROMPT', self.MOCK_SYSTEM_PROMPT):
+ with patch('prompts.builders.SYSTEM_PROMPT', self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="text",
generation_type=params["generationType"],
@@ -246,9 +246,9 @@ class TestCreatePrompt:
{"text": "Now add a navigation menu"} # User's new request
]
}
- with patch('prompts.SYSTEM_PROMPT', self.MOCK_SYSTEM_PROMPT):
+ with patch('prompts.builders.SYSTEM_PROMPT', self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="text",
generation_type=params["generationType"],
@@ -310,7 +310,7 @@ class TestCreatePrompt:
}
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="video",
generation_type=params["generationType"],
@@ -361,9 +361,9 @@ class TestCreatePrompt:
]
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -433,9 +433,9 @@ class TestCreatePrompt:
]
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -510,9 +510,9 @@ class TestCreatePrompt:
]
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -566,9 +566,9 @@ class TestCreatePrompt:
]
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -620,8 +620,8 @@ class TestCreatePrompt:
],
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
- messages = await create_prompt(
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
diff --git a/backend/tests/test_prompts_additional.py b/backend/tests/test_prompts_additional.py
index a293b74e..cd24a4d2 100644
--- a/backend/tests/test_prompts_additional.py
+++ b/backend/tests/test_prompts_additional.py
@@ -8,8 +8,8 @@ from openai.types.chat import ChatCompletionMessageParam
sys.modules["moviepy"] = MagicMock()
sys.modules["moviepy.editor"] = MagicMock()
-from prompts import create_prompt
-from prompts.types import Stack
+from prompts.builders import build_prompt_messages
+from prompts.prompt_types import Stack
# Type definitions for test structures
class ExpectedResult(TypedDict):
@@ -97,9 +97,9 @@ class TestCreatePromptImageSupport:
]
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -174,9 +174,9 @@ class TestCreatePromptImageSupport:
]
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],
@@ -230,9 +230,9 @@ class TestCreatePromptImageSupport:
]
}
- with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
+ with patch("prompts.builders.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
- messages = await create_prompt(
+ messages = await build_prompt_messages(
stack=self.TEST_STACK,
input_mode="image",
generation_type=params["generationType"],