bogeumkim commited on
Commit
6b1467b
ยท
1 Parent(s): 1e5dd42

Remove unused code in app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -90
app.py CHANGED
@@ -1,90 +1,7 @@
1
- # import re
2
- # import requests
3
- # import gradio as gr
4
-
5
- # from markdownify import markdownify
6
- # from requests.exceptions import RequestException
7
-
8
- # from utils.preprocessor import Preprocessor
9
-
10
- # # https://modal.com/docs/guide/webhook-urls
11
- # MODAL_ENDPOINT = "https://auto-readme-agent--text-to-speech-gradio-app.modal.run"
12
-
13
- # def visit_webpage(url, max_output_length=40000):
14
- # """
15
- # Fetch the webpage, convert to markdown, and use Preprocessor methods.
16
- # """
17
- # try:
18
- # response = requests.get(url, timeout=20)
19
- # response.raise_for_status()
20
- # markdown_content = markdownify(response.text).strip()
21
- # markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)
22
- # # if len(markdown_content) > max_output_length:
23
- # # markdown_content = (
24
- # # markdown_content[: max_output_length // 2]
25
- # # + f"\n..._This content has been truncated to stay below {max_output_length} characters_...\n"
26
- # # + markdown_content[-max_output_length // 2 :]
27
- # # )
28
- # # Use Preprocessor class methods
29
- # section = Preprocessor.extract_section(markdown_content)
30
- # dir_paths, files = Preprocessor.extract_dirs_from_text(section)
31
- # # Format the result
32
- # result = (
33
- # f"paths: {dir_paths}\n\n"
34
- # f"files: {files}"
35
- # )
36
- # return result
37
- # except requests.exceptions.Timeout:
38
- # return "The request timed out. Please try again later or check the URL."
39
- # except RequestException as e:
40
- # return f"Error fetching the webpage: {str(e)}"
41
- # except Exception as e:
42
- # return f"An unexpected error occurred: {str(e)}"
43
-
44
- # demo = gr.Interface(
45
- # fn=visit_webpage,
46
- # inputs=[
47
- # gr.Textbox(label="Website URL"),
48
- # gr.Textbox(label="Files or folders you want to highlight in the README (comma or newline separated)")
49
- # ],
50
- # outputs=gr.Textbox(label="Extracted Section, Directory Paths, and File Paths", show_copy_button=True),
51
- # title="Webpage Section and Path Extractor",
52
- # description="Enter a website URL. This tool fetches the page, extracts a markdown section, and lists directory paths and files found in that section. You can also specify files or folders you want to highlight in the generated README."
53
- # )
54
-
55
- # if __name__ == "__main__":
56
- # demo.launch(debug=True)
57
- import re
58
  import requests
59
  import gradio as gr
60
 
61
- from markdownify import markdownify
62
-
63
- MODAL_API_URL = "https://agents-mcp-hackathon--auto-readme-agent-fastapi-app.modal.run" # Replace with your deployed Modal endpoint
64
-
65
- # def generate_readme_from_github(repo_url):
66
- # try:
67
- # response = requests.post(
68
- # MODAL_API_URL,
69
- # json={"repo_url": repo_url},
70
- # timeout=180,
71
- # )
72
- # if response.status_code == 200:
73
- # return response.json().get("readme", "No README generated.")
74
- # else:
75
- # return f"Error: {response.status_code}\n{response.text}"
76
- # except Exception as e:
77
- # return f"Exception: {str(e)}"
78
-
79
- # with gr.Blocks() as demo:
80
- # gr.Markdown("# ๐Ÿ“ GitHub Repo โ†’ README.md Generator\nPaste a public GitHub repo link to generate a draft README.md using AI.")
81
- # repo_input = gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/owner/repo")
82
- # output = gr.Textbox(label="Generated README.md", lines=20)
83
- # btn = gr.Button("Generate README")
84
- # btn.click(generate_readme_from_github, inputs=repo_input, outputs=output)
85
-
86
- # if __name__ == "__main__":
87
- # demo.launch()
88
 
89
  def generate_readme(query):
90
  try:
@@ -101,7 +18,6 @@ def generate_readme(query):
101
  return f"Exception: {str(e)}"
102
 
103
  with gr.Blocks() as demo:
104
- # ์ œ๋ชฉ ๊ฐ€์šด๋ฐ ์ •๋ ฌ
105
  gr.HTML("<h1 style='text-align:center;'>๐Ÿค– ARA: Auto README.md Agent ๐Ÿ“</h1>")
106
  repo_input = gr.Textbox(
107
  label="GitHub Repository URL",
@@ -115,7 +31,6 @@ with gr.Blocks() as demo:
115
  with gr.Row():
116
  with gr.Column():
117
  gr.Markdown("#### ๐Ÿ–ผ๏ธ Preview (Markdown Rendered)")
118
- # ์™ผ์ชฝ: ์ˆ˜์ • ๊ฐ€๋Šฅํ•œ ํ”„๋ฆฌ๋ทฐ ๋ฐ•์Šค
119
  readme_preview = gr.Textbox(
120
  lines=24,
121
  label="Preview (Markdown Rendered)",
@@ -124,17 +39,14 @@ with gr.Blocks() as demo:
124
  )
125
  with gr.Column():
126
  gr.Markdown("#### ๐Ÿ“ Markdown Rendered Preview")
127
- # ์˜ค๋ฅธ์ชฝ: ๋งˆํฌ๋‹ค์šด ๋ Œ๋”๋ง ๋ฐ•์Šค
128
  readme_markdown = gr.Markdown(value=DEFAULT_VALUE, show_copy_button=True)
129
-
130
- # ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ์™ผ์ชฝ ๋ฐ•์Šค๋งŒ ์ฑ„์›€
131
  generate_btn.click(
132
  generate_readme,
133
  inputs=repo_input,
134
  outputs=readme_preview
135
  )
136
 
137
- # ์™ผ์ชฝ ๋ฐ•์Šค๊ฐ€ ๋ฐ”๋€” ๋•Œ๋งˆ๋‹ค ์˜ค๋ฅธ์ชฝ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋„ ์ž๋™ ๋ Œ๋”๋ง
138
  readme_preview.change(
139
  lambda md: md,
140
  inputs=readme_preview,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import requests
2
  import gradio as gr
3
 
4
+ MODAL_API_URL = "https://agents-mcp-hackathon--auto-readme-agent-fastapi-app.modal.run"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  def generate_readme(query):
7
  try:
 
18
  return f"Exception: {str(e)}"
19
 
20
  with gr.Blocks() as demo:
 
21
  gr.HTML("<h1 style='text-align:center;'>๐Ÿค– ARA: Auto README.md Agent ๐Ÿ“</h1>")
22
  repo_input = gr.Textbox(
23
  label="GitHub Repository URL",
 
31
  with gr.Row():
32
  with gr.Column():
33
  gr.Markdown("#### ๐Ÿ–ผ๏ธ Preview (Markdown Rendered)")
 
34
  readme_preview = gr.Textbox(
35
  lines=24,
36
  label="Preview (Markdown Rendered)",
 
39
  )
40
  with gr.Column():
41
  gr.Markdown("#### ๐Ÿ“ Markdown Rendered Preview")
 
42
  readme_markdown = gr.Markdown(value=DEFAULT_VALUE, show_copy_button=True)
43
+
 
44
  generate_btn.click(
45
  generate_readme,
46
  inputs=repo_input,
47
  outputs=readme_preview
48
  )
49
 
 
50
  readme_preview.change(
51
  lambda md: md,
52
  inputs=readme_preview,