Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import GPT2Tokenizer, GPT2LMHeadModel
|
2 |
+
|
3 |
+
# Load pre-trained model and tokenizer
|
4 |
+
tokenizer = GPT2Tokenizer.from_pretrained("gpt-3")
|
5 |
+
model = GPT2LMHeadModel.from_pretrained("gpt-3")
|
6 |
+
|
7 |
+
# Input text description for UI
|
8 |
+
input_text = "Generate a login form with username, password, and a submit button."
|
9 |
+
|
10 |
+
# Tokenize input and generate code
|
11 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
12 |
+
output = model.generate(input_ids, max_length=100)
|
13 |
+
|
14 |
+
# Decode and print generated code
|
15 |
+
generated_code = tokenizer.decode(output[0], skip_special_tokens=True)
|
16 |
+
print(generated_code)
|