Not-Grim-Refer
commited on
Commit
Β·
a5c4f07
1
Parent(s):
34826bb
Update app.py
Browse files
app.py
CHANGED
@@ -5,14 +5,18 @@ tokenizer = AutoTokenizer.from_pretrained("merve/chatgpt-prompts-bart-long")
|
|
5 |
model = AutoModelForSeq2SeqLM.from_pretrained("merve/chatgpt-prompts-bart-long", from_tf=True)
|
6 |
|
7 |
def generate(prompt):
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
12 |
return output[0]
|
13 |
|
14 |
-
input_component = gr.Textbox(label
|
15 |
-
output_component = gr.Textbox(label
|
16 |
examples = [["photographer"], ["developer"]]
|
17 |
-
description = "This app generates ChatGPT prompts
|
18 |
-
gr.Interface(generate, inputs
|
|
|
5 |
model = AutoModelForSeq2SeqLM.from_pretrained("merve/chatgpt-prompts-bart-long", from_tf=True)
|
6 |
|
7 |
def generate(prompt):
|
8 |
+
profession = "example profession" # Replace with your desired profession
|
9 |
+
description = "example" # Replace with your desired description
|
10 |
|
11 |
+
formatted_prompt = f"You are an expert at {profession} who always {description}.\n\n"
|
12 |
+
|
13 |
+
batch = tokenizer(formatted_prompt, return_tensors="pt")
|
14 |
+
generated_ids = model.generate(batch["input_ids"], max_length=200, num_return_sequences=1)
|
15 |
output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
16 |
return output[0]
|
17 |
|
18 |
+
input_component = gr.Textbox(label="Input a persona, e.g. photographer", value="photographer")
|
19 |
+
output_component = gr.Textbox(label="Prompt")
|
20 |
examples = [["photographer"], ["developer"]]
|
21 |
+
description = "This app generates ChatGPT prompts. Enter a persona you want the prompt to be based on."
|
22 |
+
gr.Interface(generate, inputs=input_component, outputs=output_component, examples=examples, title="π¨π»βπ€ ChatGPT Prompt Generator π¨π»βπ€", description=description).launch()
|