Alexvatti commited on
Commit
099c618
·
verified ·
1 Parent(s): 0f905e8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Code Generation Pipeline
5
+ code_pipeline = pipeline("text-generation", model="Salesforce/codegen-350M-mono")
6
+
7
+ def generate_code(prompt):
8
+ output = code_pipeline(prompt, max_length=50)
9
+ return output[0]['generated_text']
10
+
11
+ # Gradio Interface
12
+ demo = gr.Interface(
13
+ fn=generate_code,
14
+ inputs=gr.Textbox(label="Enter Code Prompt"),
15
+ outputs=gr.Textbox(label="Generated Code"),
16
+ title="Code Generation with Transformers",
17
+ description="Enter a Python function header or code snippet, and the model will generate the rest."
18
+ )
19
+
20
+ demo.launch()