prompt-machine / app.py
cloudwp's picture
Update app.py
52dd5aa
raw
history blame
1.37 kB
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import gradio as gr
tokenizer = AutoTokenizer.from_pretrained("merve/chatgpt-prompts-bart-long")
model = AutoModelForSeq2SeqLM.from_pretrained("merve/chatgpt-prompts-bart-long", from_tf=True)
def generate(prompt):
batch = tokenizer(prompt, return_tensors="pt")
generated_ids = model.generate(batch["input_ids"], max_new_tokens=150)
output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
return output[0]
input_component = gr.Textbox(label = "Input a persona, e.g. photographer", value = "photographer")
output_component = gr.Textbox(label = "Prompt")
examples = [["photographer"], ["doctor"], ["developer"], ["code generator"], ["cmd terminal"], ["dolmetscher"]]
description = "This app generates ChatGPT prompts, it's based on a BART model trained on [this dataset](https://huggingface.co/datasets/fka/awesome-chatgpt-prompts) | Free GPT3.5-Turbo Chat [Now4Free](https://now4free.org). πŸ““ Simply enter a persona that you want the prompt to be generated based on. πŸ§™πŸ»πŸ§‘πŸ»β€πŸš€πŸ§‘πŸ»β€πŸŽ¨πŸ§‘πŸ»β€πŸ”¬πŸ§‘πŸ»β€πŸ’»πŸ§‘πŸΌβ€πŸ«πŸ§‘πŸ½β€πŸŒΎ"
gr.Interface(generate, inputs = input_component, outputs=output_component, examples=examples, title = "πŸ‘¨πŸ»β€πŸŽ€ Now4FreeGPT Promting Machine πŸ‘¨πŸ»β€πŸŽ€", description=description).launch()