Spaces:
Sleeping
Sleeping
Save
Browse files
app.py
CHANGED
|
@@ -102,23 +102,23 @@ def parse_response(response):
|
|
| 102 |
print(f"Error parsing response: {e}")
|
| 103 |
return []
|
| 104 |
|
| 105 |
-
import re
|
| 106 |
-
|
| 107 |
def cleanup_text(text):
|
| 108 |
"""
|
| 109 |
-
Strips braces, brackets, and
|
| 110 |
|
| 111 |
Args:
|
| 112 |
-
|
| 113 |
|
| 114 |
Returns:
|
| 115 |
-
|
| 116 |
"""
|
| 117 |
|
| 118 |
# Remove braces and brackets
|
| 119 |
text = re.sub(r'[{}\[\]\'"]', '', text)
|
| 120 |
# Remove commas
|
| 121 |
text = text.replace(',', '')
|
|
|
|
|
|
|
| 122 |
return text
|
| 123 |
|
| 124 |
# Function to update session state when selection changes
|
|
@@ -159,7 +159,7 @@ def main():
|
|
| 159 |
st.header("Step 1: Select a Framework")
|
| 160 |
|
| 161 |
# Create a radio button
|
| 162 |
-
options = ["
|
| 163 |
framework = st.radio(
|
| 164 |
"Choose a framework:",
|
| 165 |
options,
|
|
@@ -181,7 +181,8 @@ def main():
|
|
| 181 |
framework = {st.session_state['selected_option']}
|
| 182 |
selected_task = {st.session_state['selected_task']}
|
| 183 |
|
| 184 |
-
ai_prompt = f"Generate a {framework} app as follows:
|
|
|
|
| 185 |
ai_prompt = cleanup_text(ai_prompt)
|
| 186 |
|
| 187 |
st.header("Step 2: Review and Customize the Prompt")
|
|
|
|
| 102 |
print(f"Error parsing response: {e}")
|
| 103 |
return []
|
| 104 |
|
|
|
|
|
|
|
| 105 |
def cleanup_text(text):
|
| 106 |
"""
|
| 107 |
+
Strips braces, brackets, commas, and double spaces from the given text.
|
| 108 |
|
| 109 |
Args:
|
| 110 |
+
text: The text to parse.
|
| 111 |
|
| 112 |
Returns:
|
| 113 |
+
The parsed text.
|
| 114 |
"""
|
| 115 |
|
| 116 |
# Remove braces and brackets
|
| 117 |
text = re.sub(r'[{}\[\]\'"]', '', text)
|
| 118 |
# Remove commas
|
| 119 |
text = text.replace(',', '')
|
| 120 |
+
# Remove double spaces
|
| 121 |
+
text = re.sub(' +', ' ', text)
|
| 122 |
return text
|
| 123 |
|
| 124 |
# Function to update session state when selection changes
|
|
|
|
| 159 |
st.header("Step 1: Select a Framework")
|
| 160 |
|
| 161 |
# Create a radio button
|
| 162 |
+
options = ["Streamlit", "Gradio"]
|
| 163 |
framework = st.radio(
|
| 164 |
"Choose a framework:",
|
| 165 |
options,
|
|
|
|
| 181 |
framework = {st.session_state['selected_option']}
|
| 182 |
selected_task = {st.session_state['selected_task']}
|
| 183 |
|
| 184 |
+
ai_prompt = f"Generate a {framework} app as follows: \
|
| 185 |
+
{selected_task}. Make sure the code is using the latest version of {framework}."
|
| 186 |
ai_prompt = cleanup_text(ai_prompt)
|
| 187 |
|
| 188 |
st.header("Step 2: Review and Customize the Prompt")
|