Add tab in Gradio UI
Browse files
app.py
CHANGED
@@ -3,11 +3,11 @@ 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(
|
7 |
try:
|
8 |
response = requests.post(
|
9 |
MODAL_API_URL,
|
10 |
-
json={"
|
11 |
timeout=120
|
12 |
)
|
13 |
if response.status_code == 200:
|
@@ -16,42 +16,112 @@ def generate_readme(query):
|
|
16 |
return f"Error: {response.status_code}\n{response.text}"
|
17 |
except Exception as e:
|
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 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
if __name__ == "__main__":
|
57 |
-
demo.launch()
|
|
|
|
|
|
|
|
3 |
|
4 |
MODAL_API_URL = "https://agents-mcp-hackathon--auto-readme-agent-fastapi-app.modal.run"
|
5 |
|
6 |
+
def generate_readme(repo_url):
|
7 |
try:
|
8 |
response = requests.post(
|
9 |
MODAL_API_URL,
|
10 |
+
json={"repo_url": repo_url},
|
11 |
timeout=120
|
12 |
)
|
13 |
if response.status_code == 200:
|
|
|
16 |
return f"Error: {response.status_code}\n{response.text}"
|
17 |
except Exception as e:
|
18 |
return f"Exception: {str(e)}"
|
19 |
+
|
20 |
+
DEFAULT_VALUE = (
|
21 |
+
"## Hello, World!\n"
|
22 |
+
"Regardless of the outcome, it was **a truly informative and enjoyable hackathon.** \n"
|
23 |
+
"As someone who likes and is good at using Hugging Face, I hope there will be more opportunities like this! π€"
|
24 |
+
)
|
25 |
+
|
26 |
with gr.Blocks() as demo:
|
27 |
gr.HTML("<h1 style='text-align:center;'>π€ ARA: Auto README.md Agent π</h1>")
|
28 |
+
with gr.Tabs():
|
29 |
+
with gr.TabItem("README Generator"):
|
30 |
+
repo_input = gr.Textbox(
|
31 |
+
label="GitHub Repository URL",
|
32 |
+
placeholder="Enter the GitHub repository URL (e.g. https://github.com/username/repo)"
|
33 |
+
)
|
34 |
+
generate_btn = gr.Button("Generate README.md")
|
35 |
+
with gr.Row():
|
36 |
+
with gr.Column(scale=1):
|
37 |
+
gr.Markdown("### π Draft")
|
38 |
+
readme_preview = gr.Textbox(
|
39 |
+
lines=24,
|
40 |
+
label="Generated by agent",
|
41 |
+
interactive=True,
|
42 |
+
value=DEFAULT_VALUE
|
43 |
+
)
|
44 |
+
with gr.Column(scale=1):
|
45 |
+
gr.Markdown("### πΌοΈ Preview")
|
46 |
+
readme_markdown = gr.Markdown(value=DEFAULT_VALUE, show_copy_button=True)
|
47 |
+
generate_btn.click(
|
48 |
+
generate_readme,
|
49 |
+
inputs=repo_input,
|
50 |
+
outputs=readme_preview
|
51 |
+
)
|
52 |
+
readme_preview.change(
|
53 |
+
lambda md: md,
|
54 |
+
inputs=readme_preview,
|
55 |
+
outputs=readme_markdown
|
56 |
+
)
|
57 |
+
with gr.TabItem("Demo Video"):
|
58 |
+
gr.Markdown("### Demo Video")
|
59 |
+
gr.Video("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
60 |
+
with gr.TabItem("About"):
|
61 |
+
with gr.Row():
|
62 |
+
with gr.Column(scale=1):
|
63 |
+
gr.Markdown("### Service Description")
|
64 |
+
gr.Textbox(
|
65 |
+
value="This service generates README.md files for GitHub repositories using AI agents.",
|
66 |
+
lines=8,
|
67 |
+
interactive=False
|
68 |
+
)
|
69 |
+
with gr.Column(scale=1):
|
70 |
+
gr.Markdown("### Features")
|
71 |
+
gr.Textbox(
|
72 |
+
value="- Generate README.md from GitHub repo\n- Preview generated README\n- Demo video included",
|
73 |
+
lines=4,
|
74 |
+
interactive=False
|
75 |
+
)
|
76 |
+
gr.Markdown("### Future Features")
|
77 |
+
gr.Textbox(
|
78 |
+
value="- Support for multiple branches\n- Enhanced code analysis\n- User authentication",
|
79 |
+
lines=4,
|
80 |
+
interactive=False
|
81 |
+
)
|
82 |
+
|
83 |
+
# with gr.Blocks() as demo:
|
84 |
+
# gr.HTML("<h1 style='text-align:center;'>π€ ARA: Auto README.md Agent π</h1>")
|
85 |
+
# repo_input = gr.Textbox(
|
86 |
+
# label="GitHub Repository URL",
|
87 |
+
# placeholder="Enter the GitHub repository URL (e.g. https://github.com/username/repo)"
|
88 |
+
# )
|
89 |
|
90 |
+
# generate_btn = gr.Button("Generate README.md")
|
91 |
|
92 |
+
# DEFAULT_VALUE = (
|
93 |
+
# "## Hello, World!\n"
|
94 |
+
# "Regardless of the outcome, it was **a truly informative and enjoyable hackathon.** \n"
|
95 |
+
# "As someone who likes and is good at using Hugging Face, I hope there will be more opportunities like this! π€"
|
96 |
+
# )
|
97 |
|
98 |
+
# with gr.Row():
|
99 |
+
# with gr.Column():
|
100 |
+
# gr.Markdown("### π Draft")
|
101 |
+
# readme_preview = gr.Textbox(
|
102 |
+
# lines=24,
|
103 |
+
# label="Generated by agent",
|
104 |
+
# interactive=True,
|
105 |
+
# value=DEFAULT_VALUE
|
106 |
+
# )
|
107 |
+
# with gr.Column():
|
108 |
+
# gr.Markdown("### πΌοΈ Preview")
|
109 |
+
# readme_markdown = gr.Markdown(value=DEFAULT_VALUE, show_copy_button=True)
|
110 |
|
111 |
+
# generate_btn.click(
|
112 |
+
# generate_readme,
|
113 |
+
# inputs=repo_input,
|
114 |
+
# outputs=readme_preview
|
115 |
+
# )
|
116 |
|
117 |
+
# readme_preview.change(
|
118 |
+
# lambda md: md,
|
119 |
+
# inputs=readme_preview,
|
120 |
+
# outputs=readme_markdown
|
121 |
+
# )
|
122 |
|
123 |
if __name__ == "__main__":
|
124 |
+
demo.launch()
|
125 |
+
|
126 |
+
#Error: 422
|
127 |
+
#{"detail":[{"type":"missing","loc":["body","repo_url"],"msg":"Field required","input":{"query":"https://github.com/nsbg/nsbg.github.io"}}]}
|