File size: 1,644 Bytes
613efdf 11ef4ab 613efdf 11ef4ab 613efdf 11ef4ab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import os
import openai
import gradio as gr
import transformers
openai.api_key = os.environ["api"]
generator = transformers.pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
def generateBlogTopics(prompt1):
response = generator("Generate blog topics on: {}. \n \n 1. ".format(prompt1), max_length=100, do_sample=True, temperature=0.7)[0]["generated_text"]
return response
def generateBlogSections(prompt1):
response = generator("Expand the blog title in to high level blog sections: {} \n\n- Introduction: ".format(prompt1), max_length=100, do_sample=True, temperature=0.6)[0]["generated_text"]
return response
def blogSectionExpander(prompt1):
response = generator("Expand the blog section in to a detailed professional, witty and clever explanation.\n\n {}".format(prompt1), max_length=400, do_sample=True, temperature=0.7)[0]["generated_text"]
return response
input_text = gr.inputs.Textbox(lines=5, label="Enter prompt text here:")
title_section_output = gr.outputs.Textbox(label="Title & Sections")
section_expander_output = gr.outputs.Textbox(label="Section Expander")
gr.Interface(
[generateBlogTopics, generateBlogSections],
inputs=input_text,
outputs=title_section_output,
title="Blog Title & Sections Generator",
description="Generate high level sections for your blog topic",
live=False
).launch(share=True)
gr.Interface(
blogSectionExpander,
inputs=input_text,
outputs=section_expander_output,
title="Blog Section Expander",
description="Expand your blog sections with professional and clever explanation",
live=False
).launch(share=True)
|