chmawia commited on
Commit
f0d1ea9
·
verified ·
1 Parent(s): 00f3dba

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load a code-generation model (you can replace this with a better one if needed)
5
+ code_generator = pipeline("text2text-generation", model="bigcode/t5-code-generation")
6
+
7
+ def generate_code(description):
8
+ response = code_generator(description, max_length=200)[0]['generated_text']
9
+ return response
10
+
11
+ # Create a Gradio interface
12
+ iface = gr.Interface(
13
+ fn=generate_code,
14
+ inputs=gr.Textbox(lines=5, placeholder="Enter your task description here..."),
15
+ outputs=gr.Code(),
16
+ title="Text-to-Code Generator",
17
+ description="Convert natural language coding tasks into Python code!"
18
+ )
19
+
20
+ # Launch the app
21
+ if __name__ == "__main__":
22
+ iface.launch()