ag3 / app.py
abhishekt's picture
V4
d43d27c
raw
history blame
1.86 kB
import os
import openai
import gradio as gr
import transformers
openai.api_key = os.environ["api"]
def generateBlogTopics(prompt1):
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Generate blog topics on: {}. \n \n 1. ".format(prompt1),
max_tokens=100,
n=1,
stop=None,
temperature=0.7,
)
return response.choices[0].text
def generateBlogSections(prompt1):
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Expand the blog title in to high level blog sections: {} \n\n- Introduction: ".format(prompt1),
max_tokens=100,
n=1,
stop=None,
temperature=0.6,
)
return response.choices[0].text
def blogSectionExpander(prompt1):
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Expand the blog section in to a detailed professional, witty and clever explanation.\n\n {}".format(prompt1),
max_tokens=400,
n=1,
stop=None,
temperature=0.7,
)
return response.choices[0].text
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)