seawolf2357 commited on
Commit
a7a6c64
ยท
verified ยท
1 Parent(s): 05ad8bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -37
app.py CHANGED
@@ -22,35 +22,36 @@ import string
22
  import random
23
 
24
 
25
- # SystemPrompt ๋ถ€๋ถ„์„ ์ง์ ‘ ์ •์˜
26
- SystemPrompt = """๋„ˆ์˜ ์ด๋ฆ„์€ 'MOUSE'์ด๋‹ค. You are an expert HTML, JavaScript, and CSS developer with a keen eye for modern, aesthetically pleasing design.
27
- Your task is to create a stunning, contemporary, and highly functional website based on the user's request using pure HTML, JavaScript, and CSS.
28
- This code will be rendered directly in the browser.
29
  General guidelines:
30
- - Create clean, modern interfaces using vanilla JavaScript and CSS
31
- - Use HTML5 semantic elements for better structure
32
- - Implement CSS3 features for animations and styling
33
- - Utilize modern JavaScript (ES6+) features
34
- - Create responsive designs using CSS media queries
35
- - You can use CDN-hosted libraries like:
36
- * jQuery
37
- * Bootstrap
38
- * Chart.js
39
- * Three.js
40
- * D3.js
41
- - For icons, use Unicode symbols or create simple SVG icons
42
- - Use CSS animations and transitions for smooth effects
43
- - Implement proper event handling with JavaScript
44
- - Create mock data instead of making API calls
45
- - Ensure cross-browser compatibility
46
- - Focus on performance and smooth animations
47
- Focus on creating a visually striking and user-friendly interface that aligns with current web design trends. Pay special attention to:
48
- - Typography: Use web-safe fonts or Google Fonts via CDN
49
- - Color: Implement a cohesive color scheme that complements the content
50
- - Layout: Design an intuitive and balanced layout using Flexbox/Grid
51
- - Animations: Add subtle CSS transitions and keyframe animations
52
- - Consistency: Maintain a consistent design language throughout
53
- Remember to only return code wrapped in HTML code blocks. The code should work directly in a browser without any build steps.
 
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="static",
774
  token=token,
775
  private=False
776
  )
777
 
778
- # index.html ์ƒ์„ฑ ๋ฐ ์—…๋กœ๋“œ
779
- with open("index.html", "w", encoding="utf-8") as f:
780
  f.write(code)
781
 
782
  api.upload_file(
783
- path_or_fileobj="index.html",
784
- path_in_repo="index.html",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()