File size: 1,037 Bytes
5319b4f
 
e81f6db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

def explain_code(code_input):
    model = gr.load("models/Binarybardakshat/XVCLM-MIN-DECT")
    response = model(code_input)
    return response[0]['generated_text']

with gr.Blocks() as demo:
    gr.Markdown(
        """
        # XVCLM Code Explanation Chatbot
        
        [GitHub](https://github.com/binarybardakshat) | 
        [LinkedIn](https://www.linkedin.com/in/binarybardakshat) | 
        [Medium](https://medium.com/@binarybardakshat)
        """
    )
    
    with gr.Row():
        with gr.Column():
            chatbox = gr.Chatbot()
            code_input = gr.Textbox(placeholder="Enter your code snippet here...", label="Code Snippet")
        
        with gr.Column():
            submit_button = gr.Button("Explain Code")
    
    def respond(code):
        explanation = explain_code(code)
        chatbox.append(("User", code))
        chatbox.append(("XVCLM", explanation))
        return chatbox
    
    submit_button.click(respond, inputs=code_input, outputs=chatbox)

demo.launch()