|
|
|
|
|
""" |
|
Centralized configuration for the AnyCoder application. |
|
|
|
This module contains all static data and configuration values, such as |
|
system prompts, available models, demo examples, and UI constants. |
|
Separating configuration from logic makes the application easier to |
|
manage and update. |
|
""" |
|
from typing import List, Dict, Union |
|
|
|
|
|
|
|
HTML_SYSTEM_PROMPT = """ONLY USE HTML, CSS AND JAVASCRIPT. If you want to use ICON make sure to import the library first. Try to create the best UI possible by using only HTML, CSS and JAVASCRIPT. MAKE IT RESPONSIVE USING MODERN CSS. Use as much as you can modern CSS for the styling, if you can't do something with modern CSS, then use custom CSS. Also, try to elaborate as much as you can, to create something unique. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE |
|
For website redesign tasks: |
|
- Use the provided original HTML code as the starting point for redesign. |
|
- Preserve all original content, structure, and functionality. |
|
- Create a modern, responsive design with improved typography and spacing. |
|
If an image is provided, analyze it and use the visual information to better understand the user's requirements. |
|
Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text. |
|
""" |
|
|
|
GENERIC_SYSTEM_PROMPT = """You are an expert {language} developer. Write clean, idiomatic, and runnable {language} code for the user's request. If possible, include comments and best practices. Output ONLY the code inside a ``` code block, and do not include any explanations or extra text. If the user provides a file or other context, use it as a reference. If the code is for a script or app, make it as self-contained as possible. Do NOT add the language name at the top of the code output.""" |
|
|
|
HTML_SYSTEM_PROMPT_WITH_SEARCH = HTML_SYSTEM_PROMPT.replace( |
|
"ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE", |
|
"You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE" |
|
) |
|
|
|
GENERIC_SYSTEM_PROMPT_WITH_SEARCH = GENERIC_SYSTEM_PROMPT.replace( |
|
"You are an expert", |
|
"You are an expert {language} developer. You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies for {language}." |
|
) |
|
|
|
FOLLOW_UP_SYSTEM_PROMPT = """You are an expert web developer modifying an existing HTML file. |
|
The user wants to apply changes based on their request. |
|
You MUST output ONLY the changes required using the following SEARCH/REPLACE block format. Do NOT output the entire file. |
|
Explain the changes briefly *before* the blocks if necessary, but the code changes THEMSELVES MUST be within the blocks. |
|
Format Rules: |
|
1. Start with <<<<<<< SEARCH |
|
2. Provide the exact lines from the current code that need to be replaced. |
|
3. Use ======= to separate the search block from the replacement. |
|
4. Provide the new lines that should replace the original lines. |
|
5. End with >>>>>>> REPLACE |
|
6. IMPORTANT: The SEARCH block must *exactly* match the current code, including indentation and whitespace. |
|
""" |
|
|
|
|
|
SEARCH_START = "<<<<<<< SEARCH" |
|
DIVIDER = "=======" |
|
REPLACE_END = ">>>>>>> REPLACE" |
|
|
|
|
|
|
|
AVAILABLE_MODELS: List[Dict[str, str]] = [ |
|
{"name": "Moonshot Kimi-K2", "id": "moonshotai/Kimi-K2-Instruct"}, |
|
{"name": "DeepSeek V3", "id": "deepseek-ai/DeepSeek-V3-0324"}, |
|
{"name": "DeepSeek R1", "id": "deepseek-ai/DeepSeek-R1-0528"}, |
|
{"name": "ERNIE-4.5-VL", "id": "baidu/ERNIE-4.5-VL-424B-A47B-Base-PT"}, |
|
{"name": "MiniMax M1", "id": "MiniMaxAI/MiniMax-M1-80k"}, |
|
{"name": "Qwen3-235B-A22B", "id": "Qwen/Qwen3-235B-A22B"}, |
|
{"name": "SmolLM3-3B", "id": "HuggingFaceTB/SmolLM3-3B"}, |
|
{"name": "GLM-4.1V-9B-Thinking", "id": "THUDM/GLM-4.1V-9B-Thinking"}, |
|
] |
|
|
|
MULTIMODAL_MODELS: List[str] = [ |
|
"baidu/ERNIE-4.5-VL-424B-A47B-Base-PT", |
|
"THUDM/GLM-4.1V-9B-Thinking", |
|
] |
|
|
|
DEMO_LIST: List[Dict[str, str]] = [ |
|
{"title": "Todo App", "description": "Create a simple todo application with add, delete, and mark as complete functionality"}, |
|
{"title": "Calculator", "description": "Build a basic calculator with standard arithmetic operations"}, |
|
{"title": "Chat Interface", "description": "Build a chat interface with message history and user input"}, |
|
{"title": "E-commerce Product Card", "description": "Create a responsive product card for an e-commerce website"}, |
|
{"title": "Login Form", "description": "Build a modern, responsive login form with validation"}, |
|
{"title": "Dashboard Layout", "description": "Create a dashboard layout with a sidebar and main content area"}, |
|
{"title": "UI from Image", "description": "Upload an image of a UI design and I'll generate the HTML/CSS code for it"}, |
|
{"title": "Website Redesign", "description": "Enter a website URL to extract its content and redesign it"}, |
|
{"title": "Modify HTML", "description": "After generating HTML, ask me to modify it with specific changes. For example: 'Change the title to My New App'"}, |
|
] |
|
|
|
|
|
|
|
GRADIO_SUPPORTED_LANGUAGES: List[Union[str, None]] = [ |
|
"python", "c", "cpp", "markdown", "latex", "json", "html", "css", |
|
"javascript", "jinja2", "typescript", "yaml", "dockerfile", "shell", |
|
"r", "sql", "sql-msSQL", "sql-mySQL", "sql-mariaDB", "sql-sqlite", |
|
"sql-cassandra", "sql-plSQL", "sql-hive", "sql-pgSQL", "sql-gql", |
|
"sql-gpSQL", "sql-sparkSQL", "sql-esper", None |
|
] |