Demo / ideaGen.py
Zaious's picture
Update ideaGen.py
7757c3e verified
import openai
import os
from openai import OpenAI
client = OpenAI(
api_key= os.environ["gptkey"]
)
def ideagen(content_type, brand_name, product_name, target_audience, core_essence):
total_prompt_tokens_used = 0
total_completion_tokens_used = 0
print("GO")
system_prompt = [
"Please act as a professional screenwriter for video on Youtube. Youtube video should be engaging and hold the viewer's attention. Storytelling, humor, emotion, and value-adding information can all contribute to engagement. The video should always be tailored to the targeting audience and capitalizing on trends or viral topics.",
"Please act as a offline event planner at a PR marketing agency who is good at creating real world interactive campaigns at public venue, shopfront or inside a shop. An successful event should be interesting and relevant to the audience. Workshops, speakers, performances, and interactive activities can all contribute to a dynamic event. Unique and unexpected elements – a surprise guest, an innovative presentation format, a custom app, or thoughtful gifts – can make an event stand out. And through the event deliver the brand message to target audience. The idea should always be tailored to the targeting audience and capitalizing on trends or viral topics.",
"Please act as a professional planner at a digital marketing agency who is good at creating online interactive campaigns either on mobile or PC web. An interactive campaign should provide functional services or entertainment content that engage with customers. And through the engagement deliver the brand message to target audience. The idea should always be tailored to the targeting audience and capitalizing on trends or viral topics.",
"Please act as a famous Tiktok celebrity who is good at creating Tiktok video that generates millions of views. Tiktok video should capture the viewer's attention within the first few seconds. Engaging content can be humorous, emotional, informative, or visually striking. TikTok users favor content that is relatable and entertaining. TikTok is heavily driven by music and sound. Using popular songs or catchy tunes can help in gaining more traction. Original sounds also have the potential to go viral if they catch on. Given TikTok's short format, the message or story should be conveyed quickly and clearly. Videos that are to the point and easily understandable tend to perform better. Encouraging viewer interaction through calls to action, like asking viewers to leave a comment, participate in a challenge, or follow for more content, can boost engagement rates. And through the video deliver the brand message to target audience. The idea should always be tailored to the targeting audience and capitalizing on trends or viral topics. ",
"Please act as a campaign planner in a social marketing agency who is good at creating interactive campaigns on social media platform that goes viral and generates a lot of buzz. In a successful UGC campaign, an unique, memorable, and relevant hashtag is essential. It should be easy to use and share, helping to track the campaign and aggregate content. The campaign should have an engaging and clear theme or prompt that resonates with your audience. It could be a challenge, a question, a call for stories, or a creative prompt related to your brand. Offer incentives such as contests, giveaways, or the chance to be featured on your main account. Rewards motivate participation and sharing. Partner with influencers who resonate with your target audience to kickstart the campaign and inspire participation. And through the UGC campaign deliver the brand message to target audience. The idea should always be tailored to the targeting audience and capitalizing on trends or viral topics.",
"Please act as a copywriter in an advertising agency who is good at writing headlines that can engage the audience, convey the message effectively, and encourage interaction. The headline should be attention-grabbing, clear, and relevant. It's the first thing readers see, and it should make them want to read more. It should be relevant to the target audience’s interests, needs, or problems, signaling that the article contains information they will find valuable or interesting. Including keywords not only helps in SEO but also ensures that the headline is aligned with what the audience is searching for. Using active voice and action verbs can make the headline more dynamic and compelling. Headlines that include numbers or imply a list (like '5 Ways to...') are often effective because they set clear expectations for the reader. Including a personal element or addressing the reader directly (using words like 'You' or 'Your') can make the headline more relatable. And through the headline deliver the brand message to target audience. The headline should always be tailored to the targeting audience and capitalizing on trends or viral topics.",
]
messages_base = [
{"role": "system", "content": system_prompt[content_type]},
]
if content_type == 0:
messages_base.extend([{"role": "user", "content": f"According to the following information: Brand - {brand_name}, Product - {product_name}, Target Audience - {target_audience}, Core Benefit - {core_essence}."}])
messages_base.extend([{"role": "user", "content": "Please develop an engaging and creative Youtube video script showcasing the core benefit of the product."}])
messages_base.extend([{"role": "user", "content": "You may choose any genre such as fantasy, romance, historical fiction and so on - but the aim is to write something that has an outstanding plotline, engaging characters and unexpected climaxes."}])
if content_type == 1:
messages_base.extend([{"role": "user", "content": f"According to the following information: Brand - {brand_name}, Product - {product_name}, Target Audience - {target_audience}, Core Benefit - {core_essence}."}])
messages_base.extend([{"role": "user", "content": "Please develop an engaging and creative event idea showcasing the core benefit of the product."}])
messages_base.extend([{"role": "user", "content": "You may choose any place or leverage any platform such as mobile APP, website, social media even build art installations and so on - but the aim is to create idea that our target audience can't resist."}])
if content_type == 2:
messages_base.extend([{"role": "user", "content": f"According to the following information: Brand - {brand_name}, Product - {product_name}, Target Audience - {target_audience}, Core Benefit - {core_essence}."}])
messages_base.extend([{"role": "user", "content": "Please develop an engaging and creative interactive idea showcasing the core benefit of the product."}])
messages_base.extend([{"role": "user", "content": "You may choose any platform such as mobile APP, website, social media platform and so on - but the aim is to create idea that our target audience can't resist."}])
if content_type == 3:
messages_base.extend([{"role": "user", "content": f"According to the following information: Brand - {brand_name}, Product - {product_name}, Target Audience - {target_audience}, Core Benefit - {core_essence}."}])
messages_base.extend([{"role": "user", "content": "Please develop an engaging and creative Tiktok video idea showcasing the core benefit of the product. Unique and creative content tends to perform better. This could involve original ideas, creative editing, using special effects and filters innovatively, or presenting common concepts in new ways."}])
if content_type == 4:
messages_base.extend([{"role": "user", "content": f"According to the following information: Brand - {brand_name}, Product - {product_name}, Target Audience - {target_audience}, Core Benefit - {core_essence}."}])
messages_base.extend([{"role": "user", "content": "Please develop an UGC campaign idea on Instagram to encourage sharing of real and authentic content. Authentic UGC can create a more genuine connection with your audience and build trust in your brand. Please also provide 10 hashtags in 【標題】 section."}])
if content_type == 5:
messages_base.extend([{"role": "user", "content": f"According to the following information: Brand - {brand_name}, Product - {product_name}, Target Audience - {target_audience}, Core Benefit - {core_essence}."}])
messages_base.extend([{"role": "user", "content": "Please generate 10 diverse and creative headlines. Think outside the box to tap into emotions, benefits, and scenarios that resonate uniquely with target audience."}])
messages_base.extend([{"role": "user", "content": "The results only include two sections, namely 【標題】 and 【說明】 , 【說明】 is a clear and comprehensive statement without breaking it into sections"}])
messages_base.extend([{"role": "user", "content": "請發揮你的創意跟想像並盡可能描述更多細節,必須要讓看到的人有驚豔的感覺。請使用繁體中文。"}])
full_text = ""
total_price = 0
#for _ in range(loop):
response = client.chat.completions.create(
model='gpt-4o',
max_tokens=2000,
temperature=0.7,
messages=messages_base
)
completed_text = response.choices[0].message.content
total_prompt_tokens_used += response.usage.prompt_tokens
total_completion_tokens_used += response.usage.completion_tokens
price = total_prompt_tokens_used*0.005/1000 + total_completion_tokens_used*0.015/1000
full_text += completed_text + "\n\n----------\n\n"
total_price += price
full_text += "\n\n" + "price:" + str(total_price)
#return response.choices[0].message.content
return full_text