V5
Browse files
app.py
CHANGED
@@ -6,41 +6,20 @@ import transformers
|
|
6 |
openai.api_key = os.environ["api"]
|
7 |
|
8 |
|
9 |
-
def generateBlogTopics(prompt1):
|
10 |
-
response = openai.Completion.create(
|
11 |
-
engine="text-davinci-002",
|
12 |
-
prompt="Generate blog topics on: {}. \n \n 1. ".format(prompt1),
|
13 |
-
max_tokens=100,
|
14 |
-
n=1,
|
15 |
-
stop=None,
|
16 |
-
temperature=0.7,
|
17 |
-
)
|
18 |
|
19 |
-
|
20 |
|
21 |
-
def
|
22 |
-
response =
|
23 |
-
|
24 |
-
prompt="Expand the blog title in to high level blog sections: {} \n\n- Introduction: ".format(prompt1),
|
25 |
-
max_tokens=100,
|
26 |
-
n=1,
|
27 |
-
stop=None,
|
28 |
-
temperature=0.6,
|
29 |
-
)
|
30 |
|
31 |
-
|
|
|
|
|
32 |
|
33 |
def blogSectionExpander(prompt1):
|
34 |
-
response =
|
35 |
-
|
36 |
-
prompt="Expand the blog section in to a detailed professional, witty and clever explanation.\n\n {}".format(prompt1),
|
37 |
-
max_tokens=400,
|
38 |
-
n=1,
|
39 |
-
stop=None,
|
40 |
-
temperature=0.7,
|
41 |
-
)
|
42 |
-
|
43 |
-
return response.choices[0].text
|
44 |
|
45 |
input_text = gr.inputs.Textbox(lines=5, label="Enter prompt text here:")
|
46 |
|
@@ -48,7 +27,7 @@ title_section_output = gr.outputs.Textbox(label="Title & Sections")
|
|
48 |
section_expander_output = gr.outputs.Textbox(label="Section Expander")
|
49 |
|
50 |
gr.Interface(
|
51 |
-
|
52 |
inputs=input_text,
|
53 |
outputs=title_section_output,
|
54 |
title="Blog Title & Sections Generator",
|
|
|
6 |
openai.api_key = os.environ["api"]
|
7 |
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
generator = transformers.pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
|
11 |
|
12 |
+
def generateBlogTopics(prompt1):
|
13 |
+
response = generator("Generate blog topics on: {}. \n \n 1. ".format(prompt1), max_length=100, do_sample=True, temperature=0.7)[0]["generated_text"]
|
14 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
def generateBlogSections(prompt1):
|
17 |
+
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"]
|
18 |
+
return response
|
19 |
|
20 |
def blogSectionExpander(prompt1):
|
21 |
+
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"]
|
22 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
input_text = gr.inputs.Textbox(lines=5, label="Enter prompt text here:")
|
25 |
|
|
|
27 |
section_expander_output = gr.outputs.Textbox(label="Section Expander")
|
28 |
|
29 |
gr.Interface(
|
30 |
+
gradio.mix.Parallel(generateBlogTopics, generateBlogSections),
|
31 |
inputs=input_text,
|
32 |
outputs=title_section_output,
|
33 |
title="Blog Title & Sections Generator",
|