|
import json |
|
import requests |
|
import gradio as gr |
|
|
|
MODAL_API_URL = "https://agents-mcp-hackathon--auto-readme-agent-fastapi-app.modal.run" |
|
|
|
def generate_readme(repo_url): |
|
try: |
|
response = requests.post( |
|
MODAL_API_URL, |
|
json={"repo_url": repo_url}, |
|
timeout=120 |
|
) |
|
if response.status_code == 200: |
|
data = json.loads(response.text) |
|
return data["readme"] |
|
else: |
|
return f"Error: {response.status_code}\n{response.text}" |
|
except Exception as e: |
|
return f"Exception: {str(e)}" |
|
|
|
DEFAULT_VALUE = ( |
|
"## Hello, World!\n" |
|
"Regardless of the result, it was **a truly informative and enjoyable hackathon.** \n" |
|
"As someone who likes and is good at using Hugging Face, I hope there will be more opportunities like this! π€" |
|
) |
|
|
|
EMBED_HTML = '''<div style="display: flex; justify-content: center; align-items: center; margin-top: 20px;"> |
|
<iframe width="900" height="506" |
|
src="https://www.youtube.com/embed/6M9dx-uHN1Q?si=X2s2vxkcVP2LVboF" |
|
title="YouTube video player" frameborder="0" |
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" |
|
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen> |
|
</iframe> |
|
</div> |
|
''' |
|
|
|
with gr.Blocks(gr.themes.Origin()) as demo: |
|
gr.HTML("<h1 style='text-align:center;'>π€ ARA: Auto README.md Agent π</h1>") |
|
gr.HTML('<p style="text-align:center; font-size:1.2em; color:#555;">Save your README.md writing time!</p>') |
|
with gr.Tabs(): |
|
with gr.TabItem("README.md Generator"): |
|
repo_input = gr.Textbox( |
|
label="GitHub Repository URL", |
|
placeholder="Enter the GitHub repository URL (e.g. https://github.com/username/repo)" |
|
) |
|
generate_btn = gr.Button("Generate README.md") |
|
with gr.Row(): |
|
with gr.Column(scale=1): |
|
gr.Markdown("### π Draft") |
|
readme_preview = gr.Textbox( |
|
lines=24, |
|
label="Generated by agent", |
|
interactive=True, |
|
value=DEFAULT_VALUE |
|
) |
|
with gr.Column(scale=1): |
|
gr.Markdown("### πΌοΈ Preview") |
|
readme_markdown = gr.Markdown(value=DEFAULT_VALUE, show_copy_button=True) |
|
generate_btn.click( |
|
generate_readme, |
|
inputs=repo_input, |
|
outputs=readme_preview |
|
) |
|
readme_preview.change( |
|
lambda md: md, |
|
inputs=readme_preview, |
|
outputs=readme_markdown |
|
) |
|
with gr.TabItem("Demo Video"): |
|
gr.Markdown("### Demo Video") |
|
gr.HTML(EMBED_HTML) |
|
with gr.TabItem("About"): |
|
with gr.Row(): |
|
with gr.Column(scale=1): |
|
gr.Markdown("# π©βπ« Description") |
|
gr.Markdown( |
|
"This service generates README.md files for GitHub repositories using AI agents.\n\n" |
|
"**Notice:** This project still has many areas for improvement, so I plan to continue working on it even after the hackathon. " |
|
"If you're interested, feel free to contact me on [LinkedIn](https://www.linkedin.com/in/po6eumkim/) or Discord(@bogeumkim)!" |
|
) |
|
with gr.Column(scale=1): |
|
gr.Markdown("# π Current Features") |
|
gr.Markdown( |
|
"- Generate README.md draft from GitHub repository link\n" |
|
"- Preview and edit generated README\n" |
|
"- Demo video included" |
|
) |
|
gr.Markdown("# π Future Features") |
|
gr.Markdown( |
|
"- Support for multiple branches\n" |
|
"- Support for local environment\n" |
|
"- Enhanced code analysis\n" |
|
"- And more..." |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |