npc0 commited on
Commit
73046f3
·
verified ·
1 Parent(s): 3cc9662

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -29
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
- # 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,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
- value="""The goal.
 
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
- # def download_content(url):
114
- # response = requests.get(url)
115
- # response.raise_for_status()
116
- # return response.text
117
 
118
- # def replace_urls_with_content(text):
119
- # lines = text.splitlines()
120
- # for i, line in enumerate(lines):
121
- # if line.startswith('http://') or line.startswith('https://'):
122
- # try:
123
- # content = download_content(line)
124
- # lines[i] = line.split('/')[-1] + '\n```\n' + content + '\n```'
125
- # except requests.exceptions.RequestException as e:
126
- # print(f"Error downloading content from {line}: {e}")
127
- # return '\n'.join(lines)
128
 
129
- # text_input = replace_urls_with_content(text_input)
130
- # repo: ProjectRepo = generate_repo(text_input)
131
- # zip_buffer = generate_zip(repo.all_files)
132
- # st.download_button(
133
- # label="Download Code Repository",
134
- # data=zip_buffer,
135
- # file_name="output.zip",
136
- # mime="application/zip"
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
+ )