File size: 1,858 Bytes
613efdf 11ef4ab 613efdf 11ef4ab d43d27c 11ef4ab d43d27c 11ef4ab d43d27c 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
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)
|