File size: 1,924 Bytes
174c3d3 b90747c 6b1467b b90747c b57f297 174c3d3 b90747c b57f297 174c3d3 b90747c 174c3d3 b57f297 174c3d3 b90747c 174c3d3 c0f87f9 b90747c 8b8c7d0 1e5dd42 b90747c c0f87f9 1e5dd42 c0f87f9 b90747c 1e5dd42 6b1467b b90747c 8b8c7d0 b90747c 87fb172 7960667 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 57 |
import requests
import gradio as gr
MODAL_API_URL = "https://agents-mcp-hackathon--auto-readme-agent-fastapi-app.modal.run"
def generate_readme(query):
try:
response = requests.post(
MODAL_API_URL,
json={"query": query},
timeout=120
)
if response.status_code == 200:
return response.json().get("result", "No result returned.")
else:
return f"Error: {response.status_code}\n{response.text}"
except Exception as e:
return f"Exception: {str(e)}"
with gr.Blocks() as demo:
gr.HTML("<h1 style='text-align:center;'>π€ ARA: Auto README.md Agent π</h1>")
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")
DEFAULT_VALUE = "## Hello, World!\nRegardless of the hackathon result, it was **a truly informative and enjoyable hackathon.** \nAs someone who likes and is good at using Hugging Face, I hope there will be more opportunities like this! π€"
with gr.Row():
with gr.Column():
gr.Markdown("#### πΌοΈ Preview (Markdown Rendered)")
readme_preview = gr.Textbox(
lines=24,
label="Preview (Markdown Rendered)",
interactive=True,
value=DEFAULT_VALUE
)
with gr.Column():
gr.Markdown("#### π Markdown Rendered 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
)
if __name__ == "__main__":
demo.launch() |