-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigma.py
43 lines (32 loc) · 988 Bytes
/
figma.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import streamlit as st
import openai
# Mock function to return sample components
def get_figma_components(file_name):
return ['Button', 'Input', 'Navbar']
# Function to generate Angular code with GPT-3
def generate_angular(components):
prompt = f"Generate Angular code for these components: {components}"
response = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=500
)
return response.choices[0].text
st.title("Figma to Angular Converter")
# File upload
figma_file = st.file_uploader("Upload Figma file")
if figma_file:
# Get components from Figma
components = get_figma_components(figma_file.name)
# Generate Angular code
code = generate_angular(components)
# Display code output
st.code(code, language='typescript')
# Download button
st.download_button(
label='Download Angular code',
data=code,
file_name='output.component.ts'
)
else:
st.info("Upload a Figma file to get started")