Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,10 +6,10 @@ import hmac
|
|
| 6 |
from metagpt.software_company import generate_repo, ProjectRepo
|
| 7 |
import streamlit as st
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
st.title("AI Software Coder")
|
| 15 |
def check_password():
|
|
@@ -49,7 +49,8 @@ def generate_zip(files):
|
|
| 49 |
return zip_buffer
|
| 50 |
|
| 51 |
text_input = st.text_area("Enter your software development requirements here:",
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
The instructions of the task for each file example, things to do with input and output.
|
| 55 |
|
|
@@ -110,29 +111,28 @@ comments from Nick/Marc/...
|
|
| 110 |
""")
|
| 111 |
|
| 112 |
if st.button("Generate Code"):
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
st.balloons()
|
|
|
|
| 6 |
from metagpt.software_company import generate_repo, ProjectRepo
|
| 7 |
import streamlit as st
|
| 8 |
|
| 9 |
+
CONFIG_FILE_PATH = '~/.metagpt/config2.yaml'
|
| 10 |
+
if not os.path.exists(CONFIG_FILE_PATH):
|
| 11 |
+
with open(CONFIG_FILE_PATH, 'w') as f:
|
| 12 |
+
f.write(os.environ['METAGPT_CONFIG_WITH_ANTHROPIC_API'])
|
| 13 |
|
| 14 |
st.title("AI Software Coder")
|
| 15 |
def check_password():
|
|
|
|
| 49 |
return zip_buffer
|
| 50 |
|
| 51 |
text_input = st.text_area("Enter your software development requirements here:",
|
| 52 |
+
height=2000,
|
| 53 |
+
value="""The goal.
|
| 54 |
|
| 55 |
The instructions of the task for each file example, things to do with input and output.
|
| 56 |
|
|
|
|
| 111 |
""")
|
| 112 |
|
| 113 |
if st.button("Generate Code"):
|
| 114 |
+
def download_content(url):
|
| 115 |
+
response = requests.get(url)
|
| 116 |
+
response.raise_for_status()
|
| 117 |
+
return response.text
|
| 118 |
|
| 119 |
+
def replace_urls_with_content(text):
|
| 120 |
+
lines = text.splitlines()
|
| 121 |
+
for i, line in enumerate(lines):
|
| 122 |
+
if line.startswith('http://') or line.startswith('https://'):
|
| 123 |
+
try:
|
| 124 |
+
content = download_content(line)
|
| 125 |
+
lines[i] = line.split('/')[-1] + '\n```\n' + content + '\n```'
|
| 126 |
+
except requests.exceptions.RequestException as e:
|
| 127 |
+
print(f"Error downloading content from {line}: {e}")
|
| 128 |
+
return '\n'.join(lines)
|
| 129 |
|
| 130 |
+
text_input = replace_urls_with_content(text_input)
|
| 131 |
+
repo: ProjectRepo = generate_repo(text_input)
|
| 132 |
+
zip_buffer = generate_zip(repo.all_files)
|
| 133 |
+
st.download_button(
|
| 134 |
+
label="Download Code Repository",
|
| 135 |
+
data=zip_buffer,
|
| 136 |
+
file_name="output.zip",
|
| 137 |
+
mime="application/zip"
|
| 138 |
+
)
|
|
|