|
import gradio as gr |
|
from smolagents import GradioUI |
|
|
|
class CustomGradioUI(GradioUI): |
|
def launch(self, **kwargs): |
|
with gr.Blocks(fill_height=True) as demo: |
|
|
|
gr.Markdown("## Welcome my Github PR Review Agent 🤖") |
|
gr.Markdown("Follow the instructions below to interact with the agent. Type your chat message in the box and hit enter.") |
|
|
|
|
|
|
|
stored_messages = gr.State([]) |
|
file_uploads_log = gr.State([]) |
|
chatbot = gr.Chatbot( |
|
label="Agent", |
|
type="messages", |
|
avatar_images=( |
|
None, |
|
"https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/Alfred.png", |
|
), |
|
resizeable=True, |
|
scale=1, |
|
) |
|
|
|
if self.file_upload_folder is not None: |
|
upload_file = gr.File(label="Upload a file") |
|
upload_status = gr.Textbox(label="Upload Status", interactive=False, visible=False) |
|
upload_file.change( |
|
self.upload_file, |
|
[upload_file, file_uploads_log], |
|
[upload_status, file_uploads_log], |
|
) |
|
text_input = gr.Textbox(lines=1, label="Please provide a link to your github pull request for review.") |
|
text_input.submit( |
|
self.log_user_message, |
|
[text_input, file_uploads_log], |
|
[stored_messages, text_input], |
|
).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot]) |
|
demo.launch(debug=True, share=True, **kwargs) |
|
|
|
|