Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Flutter widget template #238

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions backend/prompts/imported_code_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,38 @@
Do not include markdown "```" or "```html" at the start or end.
The return result must only include the code."""

IMPORTED_CODE_VUE_CSS_SYSTEM_PROMPT = """
You are an expert Vue/CSS developer.

- Do not add comments in the code such as "<!-- Add other navigation links as needed -->" and "<!-- ... 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.

In terms of libraries,

- Use these script to include Vue so that it can run on a standalone page:
<script src="https://registry.npmmirror.com/vue/3.3.11/files/dist/vue.global.js"></script>
- Use Vue using the global build like so:
<div id="app">{{ message }}</div>
<script>
const { createApp, ref } = Vue
createApp({
setup() {
const message = ref('Hello vue!')
return {
message
}
}
}).mount('#app')
</script>
- You can use Google Fonts
- You should use pure css in <style></style> tag
- Font Awesome for icons: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>

Return only the full code in <html></html> tags.
Do not include markdown "```" or "```html" at the start or end.
The return result must only include the code."""

IMPORTED_CODE_SVG_SYSTEM_PROMPT = """
You are an expert at building SVGs.

Expand All @@ -126,11 +158,37 @@
Do not include markdown "```" or "```svg" at the start or end.
"""


IMPORTED_CODE_FLUTTER_SYSTEM_PROMPT = """
You are an expert Flutter web developer.

- Do not add comments in the code such as "<!-- Add other navigation links as needed -->" and "<!-- ... 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. The Image url should have trailing ".png" like : https://placehold.co/100x100.png )
- Generate running code like so:

import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});
....

Return only the full code of the widget.
Do not include markdown "```" or "```dart" at the start or end.
The return result must only include the code."""


IMPORTED_CODE_SYSTEM_PROMPTS = SystemPrompts(
html_tailwind=IMPORTED_CODE_TAILWIND_SYSTEM_PROMPT,
react_tailwind=IMPORTED_CODE_REACT_TAILWIND_SYSTEM_PROMPT,
bootstrap=IMPORTED_CODE_BOOTSTRAP_SYSTEM_PROMPT,
ionic_tailwind=IMPORTED_CODE_IONIC_TAILWIND_SYSTEM_PROMPT,
vue_tailwind=IMPORTED_CODE_VUE_TAILWIND_SYSTEM_PROMPT,
vue_css=IMPORTED_CODE_VUE_CSS_SYSTEM_PROMPT,
svg=IMPORTED_CODE_SVG_SYSTEM_PROMPT,
flutter=IMPORTED_CODE_FLUTTER_SYSTEM_PROMPT
)
79 changes: 79 additions & 0 deletions backend/prompts/screenshot_system_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,50 @@
"""



VUE_CSS_PROMPT = """
You are an expert Vue/Tailwind developer
You take screenshots of a reference web page from the user, and then build single page apps
using Vue and pure css.
You might also be given a screenshot(The second image) of a web page that you have already built, and asked to
update it to look more like the reference image(The first image).

- Make sure the app looks exactly like the screenshot.
- Pay close attention to background color, text color, font size, font family,
padding, margin, border, etc. Match the colors and sizes exactly.
- Use the exact text from the screenshot.
- Do not add comments in the code such as "<!-- Add other navigation links as needed -->" and "<!-- ... other news items ... -->" in place of writing the full code. WRITE THE FULL CODE.
- Repeat elements as needed to match the screenshot. 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.
- Use Vue using the global build like so:

<div id="app">{{ message }}</div>
<script>
const { createApp, ref } = Vue
createApp({
setup() {
const message = ref('Hello vue!')
return {
message
}
}
}).mount('#app')
</script>

In terms of libraries,

- Use these script to include Vue so that it can run on a standalone page:
<script src="https://registry.npmmirror.com/vue/3.3.11/files/dist/vue.global.js"></script>
- You can use Google Fonts
- Your should use pure css in <style></style> tag
- Font Awesome for icons: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>

Return only the full code in <html></html> tags.
Do not include markdown "```" or "```html" at the start or end.
The return result must only include the code.
"""


SVG_SYSTEM_PROMPT = """
You are an expert at building SVGs.
You take screenshots of a reference web page from the user, and then build a SVG that looks exactly like the screenshot.
Expand All @@ -175,11 +219,46 @@
"""



FLUTTER_PROMPT = """
You are an expert Flutter web developer
You take screenshots of a reference web page from the user, and then build single page apps
using Flutter Material UI.
You might also be given a screenshot(The second image) of a web page that you have already built, and asked to
update it to look more like the reference image(The first image).

- Make sure the app looks exactly like the screenshot.
- Pay close attention to background color, text color, font size, font family,
padding, margin, border, etc. Match the colors and sizes exactly.
- Use the exact text from the screenshot.
- Do not add comments in the code such as "<!-- Add other navigation links as needed -->" and "<!-- ... other news items ... -->" in place of writing the full code. WRITE THE FULL CODE.
- Repeat elements as needed to match the screenshot. 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.
- Generate running code like so:

import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});
....


Return only the full code of the widget.
Do not include markdown "```" or "```dart" at the start or end.
The return result must only include the code.
"""

SYSTEM_PROMPTS = SystemPrompts(
html_tailwind=HTML_TAILWIND_SYSTEM_PROMPT,
react_tailwind=REACT_TAILWIND_SYSTEM_PROMPT,
bootstrap=BOOTSTRAP_SYSTEM_PROMPT,
ionic_tailwind=IONIC_TAILWIND_SYSTEM_PROMPT,
vue_tailwind=VUE_TAILWIND_SYSTEM_PROMPT,
vue_css=VUE_CSS_PROMPT,
svg=SVG_SYSTEM_PROMPT,
flutter=FLUTTER_PROMPT,
)
4 changes: 4 additions & 0 deletions backend/prompts/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class SystemPrompts(TypedDict):
bootstrap: str
ionic_tailwind: str
vue_tailwind: str
vue_css: str
svg: str
flutter:str


Stack = Literal[
Expand All @@ -16,5 +18,7 @@ class SystemPrompts(TypedDict):
"bootstrap",
"ionic_tailwind",
"vue_tailwind",
"vue_css",
"svg",
"flutter",
]
22 changes: 19 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.9'


services:
backend:

build:
context: ./backend
dockerfile: Dockerfile
Expand All @@ -17,11 +17,27 @@ services:
ports:
- "${BACKEND_PORT:-7001}:${BACKEND_PORT:-7001}"

command: poetry run uvicorn main:app --host 0.0.0.0 --port ${BACKEND_PORT:-7001}
command: poetry run uvicorn main:app --host 0.0.0.0 --port ${BACKEND_PORT:-7001} --workers 2

restart: always

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "5173:5173"

restart: always

nginx:
image: nginx:latest
restart: always
depends_on:
- backend
- frontend
ports:
- "80:5173"
network_mode: host
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf # 挂载自定义的nginx配置文件