File size: 217 Bytes
461845f
 
 
 
 
 
 
1
2
3
4
5
6
7
from transformers import pipeline

model = pipeline("text-generation", model="gpt2")

def generate_text(prompt, max_length=100):
    output = model(prompt, max_length=max_length)
    return output[0]["generated_text"]