-
Notifications
You must be signed in to change notification settings - Fork 1
/
content_generation.py
40 lines (34 loc) · 1.13 KB
/
content_generation.py
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
import openai
import os
# Load your OpenAI API key from an environment variable
openai.api_key = os.getenv("OPENAI_API_KEY")
# Define the categories and topics for the content
categories = [
"content that inspires you",
"content that entertains you",
"content that educates you",
"content that shares your views",
"content that makes you think",
]
topics = ["Technology", "Fullstack Development", "Artificial Intelligence"]
def generate_linkedin_post(category, topic):
prompt = (
f"Write a short, precise, and psychologically persuasive LinkedIn post "
f"for a software development agency, about {category} related to {topic}"
)
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
).choices[0].text
return response
# Generate text for each category and topic
for category in categories:
for topic in topics:
generated_text = generate_linkedin_post(category, topic)
print("Generated LinkedIn Post:")
print(generated_text)
print("\n")