| import gradio as gr | |
| from agent.core import run_agent | |
| async def respond_to_issue(issue_url, branch_name): | |
| try: | |
| result = await run_agent(issue_url, branch_name) | |
| response = "Agent has successfully processed the issue and posted an update in the comments. Check the GitHub issue for updates." | |
| except Exception as e: | |
| response = f"Something went wrong: {str(e)}" | |
| return response | |
| theme = gr.themes.Soft( | |
| primary_hue="orange", | |
| secondary_hue="yellow", | |
| neutral_hue="zinc", | |
| ) | |
| with gr.Blocks(title="OpenSorus – AI Maintainer Agent", theme=theme) as demo: | |
| gr.Markdown(""" | |
| # OpenSorus – AI Maintainer Agent for GitHub Issues | |
| **Reads the issue. Understands your repo. Replies in seconds.** | |
| Let OpenSorus handle your first-level triage by autonomously pulling context from your codebase and commenting with a helpful fix/suggestion to help your contributors/customers. | |
| **Note**: Please [install the agent](https://github.com/apps/opensorus) in your GitHub for a particular repository before using this tool. | |
| - **Quickest way to assign issue to OpenSorus**: Just mention @opensorus in the GitHub issue comments. | |
| - Alternatively, use this space to assign the issue by pasting the issue URL below & specifying the primary branch name of your codebase (e.g., main, master, etc.). | |
| --- | |
| """) | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| issue_url = gr.Textbox(label="🔗 GitHub Issue URL", placeholder="https://github.com/user/repo/issues/123") | |
| branch_name = gr.Textbox(label="🌿 Branch Name", placeholder="main or dev or feature/xyz") | |
| submit_btn = gr.Button("🚀 Run Agent", variant="primary") | |
| with gr.Column(scale=1): | |
| output_box = gr.Textbox(label="💬 Task Status", placeholder="Waiting for updates from the agent...", lines=6) | |
| submit_btn.click(fn=respond_to_issue, inputs=[issue_url, branch_name], outputs=output_box) | |
| gr.Markdown(""" | |
| --- | |
| ### 🛠 How It Works | |
| 1. [Install OpenSorus](https://github.com/apps/opensorus) as a GitHub App. | |
| 2. Configure the app to have access to your particular repository. | |
| 3. Mention @opensorus in any issue's comments. | |
| 4. Alternatively, use this space to paste the issue URL and specify the branch name (e.g., main, master, etc.). | |
| 5. Click Run Agent and OpenSorus will fetch issue details, read your code, and post a helpful comment. | |
| > ### _OpenSorus is just like an L1 dev support assistant of your project that never sleeps — and knows your codebase ✨._ | |
| --- | |
| """) | |
| if __name__ == "__main__": | |
| demo.launch() |