import gradio as gr from transformers import AutoModelForCausalLM, AutoTokenizer # Load the uncensoredgpt model and tokenizer model_name = "gpt2" # Replace with the actual uncensoredgpt model name if available model = AutoModelForCausalLM.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name) def generate_text(prompt, max_length=100): inputs = tokenizer.encode(prompt, return_tensors="pt") outputs = model.generate(inputs, max_length=max_length, num_return_sequences=1) generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True) return generated_text # Create the Gradio interface iface = gr.Interface( fn=generate_text, inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."), outputs="text", title="UncensoredGPT", description="A simple interface for the uncensoredgpt model." ) # Launch the interface iface.launch()