Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,35 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def explain_code(code_input):
|
4 |
+
model = gr.load("models/Binarybardakshat/XVCLM-MIN-DECT")
|
5 |
+
response = model(code_input)
|
6 |
+
return response[0]['generated_text']
|
7 |
+
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
gr.Markdown(
|
10 |
+
"""
|
11 |
+
# XVCLM Code Explanation Chatbot
|
12 |
+
|
13 |
+
[GitHub](https://github.com/binarybardakshat) |
|
14 |
+
[LinkedIn](https://www.linkedin.com/in/binarybardakshat) |
|
15 |
+
[Medium](https://medium.com/@binarybardakshat)
|
16 |
+
"""
|
17 |
+
)
|
18 |
+
|
19 |
+
with gr.Row():
|
20 |
+
with gr.Column():
|
21 |
+
chatbox = gr.Chatbot()
|
22 |
+
code_input = gr.Textbox(placeholder="Enter your code snippet here...", label="Code Snippet")
|
23 |
+
|
24 |
+
with gr.Column():
|
25 |
+
submit_button = gr.Button("Explain Code")
|
26 |
+
|
27 |
+
def respond(code):
|
28 |
+
explanation = explain_code(code)
|
29 |
+
chatbox.append(("User", code))
|
30 |
+
chatbox.append(("XVCLM", explanation))
|
31 |
+
return chatbox
|
32 |
+
|
33 |
+
submit_button.click(respond, inputs=code_input, outputs=chatbox)
|
34 |
+
|
35 |
+
demo.launch()
|