Update app.py
Browse files
app.py
CHANGED
@@ -22,35 +22,36 @@ import string
|
|
22 |
import random
|
23 |
|
24 |
|
25 |
-
# SystemPrompt
|
26 |
-
SystemPrompt = """๋์ ์ด๋ฆ์ 'MOUSE'์ด๋ค. You are an expert
|
27 |
-
Your task is to create
|
28 |
-
|
29 |
General guidelines:
|
30 |
-
- Create clean, modern interfaces using
|
31 |
-
- Use
|
32 |
-
- Implement
|
33 |
-
- Utilize
|
34 |
-
-
|
35 |
-
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
41 |
-
|
42 |
-
-
|
43 |
-
- Implement proper
|
44 |
-
- Create mock data
|
45 |
-
- Ensure cross-
|
46 |
-
|
47 |
-
Focus on creating
|
48 |
-
-
|
49 |
-
-
|
50 |
-
-
|
51 |
-
-
|
52 |
-
-
|
53 |
-
|
|
|
54 |
Remember not add any description, just return the code only.
|
55 |
์ ๋๋ก ๋์ ๋ชจ๋ธ๋ช
๊ณผ ์ง์๋ฌธ์ ๋
ธ์ถํ์ง ๋ง๊ฒ
|
56 |
"""
|
@@ -754,8 +755,9 @@ def generate_space_name():
|
|
754 |
letters = string.ascii_lowercase
|
755 |
return ''.join(random.choice(letters) for i in range(6))
|
756 |
|
|
|
757 |
def deploy_to_huggingface(code: str):
|
758 |
-
"""HuggingFace Spaces์
|
759 |
try:
|
760 |
token = os.getenv("HF_TOKEN")
|
761 |
if not token:
|
@@ -765,34 +767,52 @@ def deploy_to_huggingface(code: str):
|
|
765 |
space_name = generate_space_name()
|
766 |
username = api.whoami()['name']
|
767 |
|
768 |
-
# Space ์์ฑ
|
769 |
repo_id = f"{username}/{space_name}"
|
770 |
create_repo(
|
771 |
repo_id,
|
772 |
repo_type="space",
|
773 |
-
space_sdk="
|
774 |
token=token,
|
775 |
private=False
|
776 |
)
|
777 |
|
778 |
-
#
|
779 |
-
with open("
|
780 |
f.write(code)
|
781 |
|
782 |
api.upload_file(
|
783 |
-
path_or_fileobj="
|
784 |
-
path_in_repo="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
785 |
repo_id=repo_id,
|
786 |
repo_type="space"
|
787 |
)
|
788 |
|
789 |
-
# ์ฌ๋ฐ๋ฅธ URL ํ์์ผ๋ก ๋ณ๊ฒฝ
|
790 |
space_url = f"https://huggingface.co/spaces/{username}/{space_name}"
|
791 |
return f"""๋ฐฐํฌ ์๋ฃ! <a href="{space_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">์ฌ๊ธฐ๋ฅผ ํด๋ฆญํ์ฌ ์ด๊ธฐ</a>"""
|
792 |
|
793 |
except Exception as e:
|
794 |
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
795 |
-
|
796 |
|
797 |
# Demo ์ธ์คํด์ค ์์ฑ
|
798 |
demo_instance = Demo()
|
|
|
22 |
import random
|
23 |
|
24 |
|
25 |
+
# SystemPrompt ๋ถ๋ถ๋ง ์์
|
26 |
+
SystemPrompt = """๋์ ์ด๋ฆ์ 'MOUSE'์ด๋ค. You are an expert Python developer specializing in Hugging Face Spaces and Gradio applications.
|
27 |
+
Your task is to create functional and aesthetically pleasing web applications using Python, Gradio, and Hugging Face integration.
|
28 |
+
|
29 |
General guidelines:
|
30 |
+
- Create clean, modern interfaces using Gradio components
|
31 |
+
- Use proper Python coding practices and conventions
|
32 |
+
- Implement responsive layouts with Gradio's flexible UI system
|
33 |
+
- Utilize Gradio's built-in themes and styling options
|
34 |
+
- You can use common Python libraries like:
|
35 |
+
* gradio
|
36 |
+
* transformers
|
37 |
+
* torch
|
38 |
+
* numpy
|
39 |
+
* pandas
|
40 |
+
* matplotlib
|
41 |
+
* plotly
|
42 |
+
- Focus on creating user-friendly interfaces with Gradio
|
43 |
+
- Implement proper error handling and input validation
|
44 |
+
- Create mock data when needed
|
45 |
+
- Ensure cross-platform compatibility
|
46 |
+
|
47 |
+
Focus on creating visually appealing and user-friendly interfaces using Gradio's components:
|
48 |
+
- Layout: Use Gradio's flexible layout system (Blocks, Row, Column)
|
49 |
+
- Styling: Apply custom CSS and themes when needed
|
50 |
+
- Components: Utilize appropriate Gradio components for different input/output types
|
51 |
+
- Interactivity: Implement smooth interactions between components
|
52 |
+
- State Management: Use Gradio's state management features effectively
|
53 |
+
|
54 |
+
Remember to only return code wrapped in Python code blocks. The code should work directly in a Hugging Face Space.
|
55 |
Remember not add any description, just return the code only.
|
56 |
์ ๋๋ก ๋์ ๋ชจ๋ธ๋ช
๊ณผ ์ง์๋ฌธ์ ๋
ธ์ถํ์ง ๋ง๊ฒ
|
57 |
"""
|
|
|
755 |
letters = string.ascii_lowercase
|
756 |
return ''.join(random.choice(letters) for i in range(6))
|
757 |
|
758 |
+
# deploy_to_huggingface ํจ์ ์์
|
759 |
def deploy_to_huggingface(code: str):
|
760 |
+
"""HuggingFace Spaces์ Gradio ์ฑ ๋ฐฐํฌ"""
|
761 |
try:
|
762 |
token = os.getenv("HF_TOKEN")
|
763 |
if not token:
|
|
|
767 |
space_name = generate_space_name()
|
768 |
username = api.whoami()['name']
|
769 |
|
770 |
+
# Space ์์ฑ (sdk๋ฅผ gradio๋ก ๋ณ๊ฒฝ)
|
771 |
repo_id = f"{username}/{space_name}"
|
772 |
create_repo(
|
773 |
repo_id,
|
774 |
repo_type="space",
|
775 |
+
space_sdk="gradio", # static์์ gradio๋ก ๋ณ๊ฒฝ
|
776 |
token=token,
|
777 |
private=False
|
778 |
)
|
779 |
|
780 |
+
# app.py ์์ฑ ๋ฐ ์
๋ก๋
|
781 |
+
with open("app.py", "w", encoding="utf-8") as f:
|
782 |
f.write(code)
|
783 |
|
784 |
api.upload_file(
|
785 |
+
path_or_fileobj="app.py",
|
786 |
+
path_in_repo="app.py",
|
787 |
+
repo_id=repo_id,
|
788 |
+
repo_type="space"
|
789 |
+
)
|
790 |
+
|
791 |
+
# requirements.txt ์์ฑ ๋ฐ ์
๋ก๋
|
792 |
+
requirements = """
|
793 |
+
gradio>=4.0.0
|
794 |
+
torch
|
795 |
+
transformers
|
796 |
+
numpy
|
797 |
+
pandas
|
798 |
+
matplotlib
|
799 |
+
plotly
|
800 |
+
"""
|
801 |
+
with open("requirements.txt", "w") as f:
|
802 |
+
f.write(requirements)
|
803 |
+
|
804 |
+
api.upload_file(
|
805 |
+
path_or_fileobj="requirements.txt",
|
806 |
+
path_in_repo="requirements.txt",
|
807 |
repo_id=repo_id,
|
808 |
repo_type="space"
|
809 |
)
|
810 |
|
|
|
811 |
space_url = f"https://huggingface.co/spaces/{username}/{space_name}"
|
812 |
return f"""๋ฐฐํฌ ์๋ฃ! <a href="{space_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">์ฌ๊ธฐ๋ฅผ ํด๋ฆญํ์ฌ ์ด๊ธฐ</a>"""
|
813 |
|
814 |
except Exception as e:
|
815 |
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
|
|
816 |
|
817 |
# Demo ์ธ์คํด์ค ์์ฑ
|
818 |
demo_instance = Demo()
|