Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ os.environ["HF_HOME"] = "./cache" # Store model locally
|
|
| 9 |
MODEL_NAME = "Salesforce/codet5-small"
|
| 10 |
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 12 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME
|
| 13 |
|
| 14 |
def generate_code(description, language):
|
| 15 |
prompt = f"Generate {language} code: {description}"
|
|
@@ -39,6 +39,17 @@ iface = gr.Interface(
|
|
| 39 |
gr.Textbox(lines=5, placeholder="Describe your coding task..."),
|
| 40 |
gr.Dropdown(choices=["Python", "JavaScript", "Java"], label="Programming Language")
|
| 41 |
],
|
| 42 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
| 43 |
title="Multi-Language Text-to-Code AI",
|
| 44 |
-
description="Convert natural language descriptions into code in different programming languages!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
MODEL_NAME = "Salesforce/codet5-small"
|
| 10 |
|
| 11 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 12 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
|
| 13 |
|
| 14 |
def generate_code(description, language):
|
| 15 |
prompt = f"Generate {language} code: {description}"
|
|
|
|
| 39 |
gr.Textbox(lines=5, placeholder="Describe your coding task..."),
|
| 40 |
gr.Dropdown(choices=["Python", "JavaScript", "Java"], label="Programming Language")
|
| 41 |
],
|
| 42 |
+
outputs=[
|
| 43 |
+
gr.Code(label="Generated Code"),
|
| 44 |
+
gr.Textbox(label="Execution Output")
|
| 45 |
+
],
|
| 46 |
title="Multi-Language Text-to-Code AI",
|
| 47 |
+
description="Convert natural language descriptions into code in different programming languages! Run Python code directly in the app.",
|
| 48 |
+
theme="default",
|
| 49 |
+
allow_flagging="never",
|
| 50 |
+
live=True
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
# Launch the app
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
iface.launch(share=True, debug=True, server_name="0.0.0.0", server_port=7860)
|