acecalisto3 commited on
Commit
2b6e388
·
verified ·
1 Parent(s): 27dd824

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -299,12 +299,12 @@ def generate_app(user_idea, project_name):
299
  project_path = create_project(project_name)
300
 
301
  # Generate code using Codex
302
- prompt = f"Create a simple Streamlit app for the project named '{project_name}'. The app should display the following summary: '{summary}'."
303
  generated_code = codex_pipeline(prompt)[0]['generated_text']
304
 
305
  # Save the generated code to a file in the project directory
306
  with open(os.path.join(project_path, "app.py"), "w") as f:
307
- f.write(generated_code)
308
 
309
  # Deploy the app to Hugging Face Spaces
310
  deploy_app_to_hf_spaces(project_name, token, generated_code)
@@ -312,7 +312,7 @@ def generate_app(user_idea, project_name):
312
  return generated_code, project_path
313
 
314
  def deploy_app_to_hf_spaces(project_name, token, generated_code):
315
- repo_name = f"hf-{project_name}"
316
  repo_id = hf_api.changelog.get_repo_id(repo_name)
317
 
318
  if not repo_id:
@@ -323,7 +323,7 @@ def deploy_app_to_hf_spaces(project_name, token, generated_code):
323
 
324
  temp_file = "temp_code.py"
325
  with open(temp_file, "w") as f:
326
- f.write(generated_code)
327
 
328
  # Upload the file to Hugging Face Spaces
329
  api.upload_files(repo_id, [temp_file], token)
@@ -333,10 +333,10 @@ def deploy_app_to_hf_spaces(project_name, token, generated_code):
333
 
334
  def launch_chatapp(project_path):
335
  if st.button("Launch ChatApp"):
336
- st.write("Launching ChatApp...")
337
- os.chdir(project_path)
338
- subprocess.run(["python", "app.py"])
339
- st.write("ChatApp launched successfully!")
340
 
341
  def generate_app(user_idea, project_name):
342
  # Extract key information from the user idea
@@ -351,14 +351,14 @@ def deploy_app_to_hf_spaces(project_name, token, generated_code):
351
 
352
  # Save the generated code to a file in the project directory
353
  with open(os.path.join(project_path, "app.py"), "w") as f:
354
- f.write(generated_code)
355
 
356
  # Upload the file to Hugging Face Spaces
357
  api = HfApi()
358
  repo_id = create_repo(api, project_name)["repo_id"]
359
  temp_file = "temp_code.py"
360
  with open(temp_file, "w") as f:
361
- f.write(generated_code)
362
  api.upload_files(repo_id, [temp_file], api.api_key)
363
 
364
  # Delete the temporary file
 
299
  project_path = create_project(project_name)
300
 
301
  # Generate code using Codex
302
+ prompt = f"""Create a simple Streamlit app for the project named '{project_name}'. The app should display the following summary: '{summary}'."""
303
  generated_code = codex_pipeline(prompt)[0]['generated_text']
304
 
305
  # Save the generated code to a file in the project directory
306
  with open(os.path.join(project_path, "app.py"), "w") as f:
307
+ f"""write(generated_code)"""
308
 
309
  # Deploy the app to Hugging Face Spaces
310
  deploy_app_to_hf_spaces(project_name, token, generated_code)
 
312
  return generated_code, project_path
313
 
314
  def deploy_app_to_hf_spaces(project_name, token, generated_code):
315
+ repo_name = f"""hf-{project_name}"""
316
  repo_id = hf_api.changelog.get_repo_id(repo_name)
317
 
318
  if not repo_id:
 
323
 
324
  temp_file = "temp_code.py"
325
  with open(temp_file, "w") as f:
326
+ f"""write(generated_code)"""
327
 
328
  # Upload the file to Hugging Face Spaces
329
  api.upload_files(repo_id, [temp_file], token)
 
333
 
334
  def launch_chatapp(project_path):
335
  if st.button("Launch ChatApp"):
336
+ st.write("Launching ChatApp...")
337
+ os.chdir(project_path)
338
+ subprocess.run(["python", "app.py"])
339
+ st.write("ChatApp launched successfully!")
340
 
341
  def generate_app(user_idea, project_name):
342
  # Extract key information from the user idea
 
351
 
352
  # Save the generated code to a file in the project directory
353
  with open(os.path.join(project_path, "app.py"), "w") as f:
354
+ f"""write(generated_code)"""
355
 
356
  # Upload the file to Hugging Face Spaces
357
  api = HfApi()
358
  repo_id = create_repo(api, project_name)["repo_id"]
359
  temp_file = "temp_code.py"
360
  with open(temp_file, "w") as f:
361
+ f"""write(generated_code)"""
362
  api.upload_files(repo_id, [temp_file], api.api_key)
363
 
364
  # Delete the temporary file