yasserrmd commited on
Commit
3440da7
1 Parent(s): 90f73f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -16,7 +16,7 @@ def generate_documentation(code_input):
16
  prompt = f"Generate README for the following code:\n\n{code_input}"
17
 
18
  messages = [
19
- {"role": "system", "content": "You are CodeDocify, a highly efficient and intelligent assistant designed to analyze code and generate comprehensive, clear, and concise documentation. Your purpose is to help developers by producing well-structured README files and detailed explanations of their code. You aim to simplify complex code into easily understandable documentation, ensuring that your responses are accurate, professional, and easy to follow."},
20
  {"role": "user", "content": prompt}
21
  ]
22
 
@@ -35,13 +35,13 @@ def generate_documentation(code_input):
35
  # Gradio interface
36
  def process_code(code_input):
37
  documentation = generate_documentation(code_input)
38
- readme_file = io.BytesIO()
39
- readme_file.write(documentation.encode('utf-8'))
40
- readme_file.seek(0)
 
41
 
42
- return documentation, readme_file
43
 
44
- # Set up the Gradio app with Bootstrap, icons, and smiley
45
  with gr.Blocks(css=".container { font-family: 'Roboto', sans-serif; } .btn-primary { background-color: #007bff; } .icon { margin-right: 10px; }") as app:
46
  gr.Markdown("""
47
  #Code Documentation Generator
 
16
  prompt = f"Generate README for the following code:\n\n{code_input}"
17
 
18
  messages = [
19
+ {"role": "system", "content": "You are ReadMe Forge, a highly efficient and intelligent assistant designed to analyze code and generate comprehensive, clear, and concise documentation. Your purpose is to help developers by producing well-structured README files and detailed explanations of their code. You aim to simplify complex code into easily understandable documentation, ensuring that your responses are accurate, professional, and easy to follow."},
20
  {"role": "user", "content": prompt}
21
  ]
22
 
 
35
  # Gradio interface
36
  def process_code(code_input):
37
  documentation = generate_documentation(code_input)
38
+ # Save the documentation to a README.md file
39
+ file_path = "README.md"
40
+ with open(file_path, 'w', encoding='utf-8') as readme_file:
41
+ readme_file.write(documentation)
42
 
43
+ return documentation, file_path
44
 
 
45
  with gr.Blocks(css=".container { font-family: 'Roboto', sans-serif; } .btn-primary { background-color: #007bff; } .icon { margin-right: 10px; }") as app:
46
  gr.Markdown("""
47
  #Code Documentation Generator