|
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) |
|
|