mgbam commited on
Commit
f60d626
·
verified ·
1 Parent(s): df76ae8

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +91 -189
config.py CHANGED
@@ -1,190 +1,92 @@
1
- # Gradio supported languages for syntax highlighting
2
- GRADIO_SUPPORTED_LANGUAGES = [
3
- "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
4
- ]
5
-
6
- # Search/Replace Constants
7
- SEARCH_START = "<<<<<<< SEARCH"
8
- DIVIDER = "======="
9
- REPLACE_END = ">>>>>>> REPLACE"
10
-
11
- # Configuration
12
- 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
13
- For website redesign tasks:
14
- - Use the provided original HTML code as the starting point for redesign
15
- - Preserve all original content, structure, and functionality
16
- - Keep the same semantic HTML structure but enhance the styling
17
- - Reuse all original images and their URLs from the HTML code
18
- - Create a modern, responsive design with improved typography and spacing
19
- - Use modern CSS frameworks and design patterns
20
- - Ensure accessibility and mobile responsiveness
21
- - Maintain the same navigation and user flow
22
- - Enhance the visual design while keeping the original layout structure
23
- If an image is provided, analyze it and use the visual information to better understand the user's requirements.
24
- Always respond with code that can be executed or rendered directly.
25
- Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text."""
26
-
27
- 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 ```{language} ... ``` 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."""
28
-
29
- # System prompt with search capability
30
- HTML_SYSTEM_PROMPT_WITH_SEARCH = """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
31
- You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies.
32
- For website redesign tasks:
33
- - Use the provided original HTML code as the starting point for redesign
34
- - Preserve all original content, structure, and functionality
35
- - Keep the same semantic HTML structure but enhance the styling
36
- - Reuse all original images and their URLs from the HTML code
37
- - Use web search to find current design trends and best practices for the specific type of website
38
- - Create a modern, responsive design with improved typography and spacing
39
- - Use modern CSS frameworks and design patterns
40
- - Ensure accessibility and mobile responsiveness
41
- - Maintain the same navigation and user flow
42
- - Enhance the visual design while keeping the original layout structure
43
- If an image is provided, analyze it and use the visual information to better understand the user's requirements.
44
- Always respond with code that can be executed or rendered directly.
45
- Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text."""
46
-
47
- GENERIC_SYSTEM_PROMPT_WITH_SEARCH = """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}.
48
- 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 ```{language} ... ``` 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."""
49
-
50
- # Follow-up system prompt for modifying existing HTML files
51
- FollowUpSystemPrompt = f"""You are an expert web developer modifying an existing HTML file.
52
- The user wants to apply changes based on their request.
53
- You MUST output ONLY the changes required using the following SEARCH/REPLACE block format. Do NOT output the entire file.
54
- Explain the changes briefly *before* the blocks if necessary, but the code changes THEMSELVES MUST be within the blocks.
55
- Format Rules:
56
- 1. Start with {SEARCH_START}
57
- 2. Provide the exact lines from the current code that need to be replaced.
58
- 3. Use {DIVIDER} to separate the search block from the replacement.
59
- 4. Provide the new lines that should replace the original lines.
60
- 5. End with {REPLACE_END}
61
- 6. You can use multiple SEARCH/REPLACE blocks if changes are needed in different parts of the file.
62
- 7. To insert code, use an empty SEARCH block (only {SEARCH_START} and {DIVIDER} on their lines) if inserting at the very beginning, otherwise provide the line *before* the insertion point in the SEARCH block and include that line plus the new lines in the REPLACE block.
63
- 8. To delete code, provide the lines to delete in the SEARCH block and leave the REPLACE block empty (only {DIVIDER} and {REPLACE_END} on their lines).
64
- 9. IMPORTANT: The SEARCH block must *exactly* match the current code, including indentation and whitespace.
65
- Example Modifying Code:
66
- ```
67
- Some explanation...
68
- {SEARCH_START}
69
- <h1>Old Title</h1>
70
- {DIVIDER}
71
- <h1>New Title</h1>
72
- {REPLACE_END}
73
- {SEARCH_START}
74
- </body>
75
- {DIVIDER}
76
- <script>console.log("Added script");</script>
77
- </body>
78
- {REPLACE_END}
79
- ```
80
- Example Deleting Code:
81
- ```
82
- Removing the paragraph...
83
- {SEARCH_START}
84
- <p>This paragraph will be deleted.</p>
85
- {DIVIDER}
86
- {REPLACE_END}
87
- ```"""
88
-
89
- # Available models
90
- AVAILABLE_MODELS = [
91
- {
92
- "name": "Moonshot Kimi-K2",
93
- "id": "moonshotai/Kimi-K2-Instruct",
94
- "description": "Moonshot AI Kimi-K2-Instruct model for code generation and general tasks"
95
- },
96
- {
97
- "name": "DeepSeek V3",
98
- "id": "deepseek-ai/DeepSeek-V3-0324",
99
- "description": "DeepSeek V3 model for code generation"
100
- },
101
- {
102
- "name": "DeepSeek R1",
103
- "id": "deepseek-ai/DeepSeek-R1-0528",
104
- "description": "DeepSeek R1 model for code generation"
105
- },
106
- {
107
- "name": "ERNIE-4.5-VL",
108
- "id": "baidu/ERNIE-4.5-VL-424B-A47B-Base-PT",
109
- "description": "ERNIE-4.5-VL model for multimodal code generation with image support"
110
- },
111
- {
112
- "name": "MiniMax M1",
113
- "id": "MiniMaxAI/MiniMax-M1-80k",
114
- "description": "MiniMax M1 model for code generation and general tasks"
115
- },
116
- {
117
- "name": "Qwen3-235B-A22B",
118
- "id": "Qwen/Qwen3-235B-A22B",
119
- "description": "Qwen3-235B-A22B model for code generation and general tasks"
120
- },
121
- {
122
- "name": "SmolLM3-3B",
123
- "id": "HuggingFaceTB/SmolLM3-3B",
124
- "description": "SmolLM3-3B model for code generation and general tasks"
125
- },
126
- {
127
- "name": "GLM-4.1V-9B-Thinking",
128
- "id": "THUDM/GLM-4.1V-9B-Thinking",
129
- "description": "GLM-4.1V-9B-Thinking model for multimodal code generation with image support"
130
- }
131
- ]
132
-
133
- DEMO_LIST = [
134
- {
135
- "title": "Todo App",
136
- "description": "Create a simple todo application with add, delete, and mark as complete functionality"
137
- },
138
- {
139
- "title": "Calculator",
140
- "description": "Build a basic calculator with addition, subtraction, multiplication, and division"
141
- },
142
- {
143
- "title": "Weather Dashboard",
144
- "description": "Create a weather dashboard that displays current weather information"
145
- },
146
- {
147
- "title": "Chat Interface",
148
- "description": "Build a chat interface with message history and user input"
149
- },
150
- {
151
- "title": "E-commerce Product Card",
152
- "description": "Create a product card component for an e-commerce website"
153
- },
154
- {
155
- "title": "Login Form",
156
- "description": "Build a responsive login form with validation"
157
- },
158
- {
159
- "title": "Dashboard Layout",
160
- "description": "Create a dashboard layout with sidebar navigation and main content area"
161
- },
162
- {
163
- "title": "Data Table",
164
- "description": "Build a data table with sorting and filtering capabilities"
165
- },
166
- {
167
- "title": "Image Gallery",
168
- "description": "Create an image gallery with lightbox functionality and responsive grid layout"
169
- },
170
- {
171
- "title": "UI from Image",
172
- "description": "Upload an image of a UI design and I'll generate the HTML/CSS code for it"
173
- },
174
- {
175
- "title": "Extract Text from Image",
176
- "description": "Upload an image containing text and I'll extract and process the text content"
177
- },
178
- {
179
- "title": "Website Redesign",
180
- "description": "Enter a website URL to extract its content and redesign it with a modern, responsive layout"
181
- },
182
- {
183
- "title": "Modify HTML",
184
- "description": "After generating HTML, ask me to modify it with specific changes using search/replace format"
185
- },
186
- {
187
- "title": "Search/Replace Example",
188
- "description": "Generate HTML first, then ask: 'Change the title to My New Title' or 'Add a blue background to the body'"
189
- }
190
  ]
 
1
+ # /config.py
2
+
3
+ """
4
+ Centralized configuration for the AnyCoder application.
5
+
6
+ This module contains all static data and configuration values, such as
7
+ system prompts, available models, demo examples, and UI constants.
8
+ Separating configuration from logic makes the application easier to
9
+ manage and update.
10
+ """
11
+ from typing import List, Dict, Union
12
+
13
+ # --- System Prompts ---
14
+
15
+ 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
16
+ For website redesign tasks:
17
+ - Use the provided original HTML code as the starting point for redesign.
18
+ - Preserve all original content, structure, and functionality.
19
+ - Create a modern, responsive design with improved typography and spacing.
20
+ If an image is provided, analyze it and use the visual information to better understand the user's requirements.
21
+ Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text.
22
+ """
23
+
24
+ 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."""
25
+
26
+ HTML_SYSTEM_PROMPT_WITH_SEARCH = HTML_SYSTEM_PROMPT.replace(
27
+ "ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE",
28
+ "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"
29
+ )
30
+
31
+ GENERIC_SYSTEM_PROMPT_WITH_SEARCH = GENERIC_SYSTEM_PROMPT.replace(
32
+ "You are an expert",
33
+ "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}."
34
+ )
35
+
36
+ FOLLOW_UP_SYSTEM_PROMPT = """You are an expert web developer modifying an existing HTML file.
37
+ The user wants to apply changes based on their request.
38
+ You MUST output ONLY the changes required using the following SEARCH/REPLACE block format. Do NOT output the entire file.
39
+ Explain the changes briefly *before* the blocks if necessary, but the code changes THEMSELVES MUST be within the blocks.
40
+ Format Rules:
41
+ 1. Start with <<<<<<< SEARCH
42
+ 2. Provide the exact lines from the current code that need to be replaced.
43
+ 3. Use ======= to separate the search block from the replacement.
44
+ 4. Provide the new lines that should replace the original lines.
45
+ 5. End with >>>>>>> REPLACE
46
+ 6. IMPORTANT: The SEARCH block must *exactly* match the current code, including indentation and whitespace.
47
+ """
48
+
49
+ # --- Search/Replace Constants ---
50
+ SEARCH_START = "<<<<<<< SEARCH"
51
+ DIVIDER = "======="
52
+ REPLACE_END = ">>>>>>> REPLACE"
53
+
54
+ # --- Models & UI ---
55
+
56
+ AVAILABLE_MODELS: List[Dict[str, str]] = [
57
+ {"name": "Moonshot Kimi-K2", "id": "moonshotai/Kimi-K2-Instruct"},
58
+ {"name": "DeepSeek V3", "id": "deepseek-ai/DeepSeek-V3-0324"},
59
+ {"name": "DeepSeek R1", "id": "deepseek-ai/DeepSeek-R1-0528"},
60
+ {"name": "ERNIE-4.5-VL", "id": "baidu/ERNIE-4.5-VL-424B-A47B-Base-PT"},
61
+ {"name": "MiniMax M1", "id": "MiniMaxAI/MiniMax-M1-80k"},
62
+ {"name": "Qwen3-235B-A22B", "id": "Qwen/Qwen3-235B-A22B"},
63
+ {"name": "SmolLM3-3B", "id": "HuggingFaceTB/SmolLM3-3B"},
64
+ {"name": "GLM-4.1V-9B-Thinking", "id": "THUDM/GLM-4.1V-9B-Thinking"},
65
+ ]
66
+
67
+ MULTIMODAL_MODELS: List[str] = [
68
+ "baidu/ERNIE-4.5-VL-424B-A47B-Base-PT",
69
+ "THUDM/GLM-4.1V-9B-Thinking",
70
+ ]
71
+
72
+ DEMO_LIST: List[Dict[str, str]] = [
73
+ {"title": "Todo App", "description": "Create a simple todo application with add, delete, and mark as complete functionality"},
74
+ {"title": "Calculator", "description": "Build a basic calculator with standard arithmetic operations"},
75
+ {"title": "Chat Interface", "description": "Build a chat interface with message history and user input"},
76
+ {"title": "E-commerce Product Card", "description": "Create a responsive product card for an e-commerce website"},
77
+ {"title": "Login Form", "description": "Build a modern, responsive login form with validation"},
78
+ {"title": "Dashboard Layout", "description": "Create a dashboard layout with a sidebar and main content area"},
79
+ {"title": "UI from Image", "description": "Upload an image of a UI design and I'll generate the HTML/CSS code for it"},
80
+ {"title": "Website Redesign", "description": "Enter a website URL to extract its content and redesign it"},
81
+ {"title": "Modify HTML", "description": "After generating HTML, ask me to modify it with specific changes. For example: 'Change the title to My New App'"},
82
+ ]
83
+
84
+ # --- Supported Languages for Gradio Syntax Highlighting ---
85
+ # From: https://www.gradio.app/docs/code
86
+ GRADIO_SUPPORTED_LANGUAGES: List[Union[str, None]] = [
87
+ "python", "c", "cpp", "markdown", "latex", "json", "html", "css",
88
+ "javascript", "jinja2", "typescript", "yaml", "dockerfile", "shell",
89
+ "r", "sql", "sql-msSQL", "sql-mySQL", "sql-mariaDB", "sql-sqlite",
90
+ "sql-cassandra", "sql-plSQL", "sql-hive", "sql-pgSQL", "sql-gql",
91
+ "sql-gpSQL", "sql-sparkSQL", "sql-esper", None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  ]