| | import openai |
| | import os |
| |
|
| | from openai import OpenAI |
| | client = OpenAI( |
| | api_key= os.environ["gptkey"] |
| | ) |
| | def ideagen(content_type,context): |
| | total_prompt_tokens_used = 0 |
| | total_completion_tokens_used = 0 |
| |
|
| | print(context) |
| |
|
| | messages_base = [ |
| | {"role": "system", "content": "請扮演一個充滿創意與靈感的資深企劃"}, |
| | ] |
| |
|
| | if content_type == 0: |
| | messages_base.extend([{"role": "user", "content": f"這是我之前請你產生的 captivating title and concept for a YouTube film . Imagine a visual narrative that showcases the product in diverse scenarios, engaging viewers and prompting shares."}]) |
| | messages_base.extend([{"role": "user", "content": f"接下來,請你根據之前生成的 {context} ,給我【分鏡畫面敘述】:這個影片的每一個分鏡畫面的詳述,至少十個分鏡;【拍攝要點】 :總結拍攝這個影片要注意維持的核心要素與氛圍"}]) |
| | messages_base.extend([{"role": "user", "content": "請發揮你的創意跟想像並盡可能描述更多細節,必須要讓看到的人有驚豔的感覺。請使用繁體中文。"}]) |
| |
|
| | if content_type == 1: |
| | messages_base.extend([{"role": "user", "content": f"這是我之前請你產生的 in-store activation or live event . a space within the store, ensuring memorable product interactions."}]) |
| | messages_base.extend([{"role": "user", "content": f"接下來,請你根據之前生成的 {context} ,給我【活動流程】:列出舉辦這個活動的每一個步驟流程的詳述,至少十個步驟;【籌備要點】 :補充要實際舉辦這個活動可能的注意事項"}]) |
| | messages_base.extend([{"role": "user", "content": "請發揮你的創意跟想像並盡可能描述更多細節,必須要讓看到的人有驚豔的感覺。請使用繁體中文。"}]) |
| |
|
| | if content_type == 2: |
| | messages_base.extend([{"role": "user", "content": f"這是我之前請你產生的 digital or mobile user-centric platform or app that harnesses cutting-edge technology , ensuring engaging and memorable interactions."}]) |
| | messages_base.extend([{"role": "user", "content": f"接下來,請你根據之前生成的 {context} ,給我【互動流程】:列出這個互動體驗的每一個步驟流程的詳述,至少十個步驟;【製作要點】 :補充要實際製作這個互動體驗可能的注意事項"}]) |
| | messages_base.extend([{"role": "user", "content": "請發揮你的創意跟想像並盡可能描述更多細節,必須要讓看到的人有驚豔的感覺。請使用繁體中文。"}]) |
| |
|
| | if content_type == 3: |
| | messages_base.extend([{"role": "user", "content": f"這是我之前請你產生的 TikTok short video script that resonates with young audiences. Incorporate trendy music, relatable scenarios. Think about popular TikTok trends, challenges, and storytelling methods that captivate the youth. Consider how to integrate these elements seamlessly into a narrative that highlights the product's features in a fun and engaging way."}]) |
| | messages_base.extend([{"role": "user", "content": f"接下來,請你根據之前生成的 {context} ,給我【分鏡畫面敘述】:這個影片的每一個分鏡畫面的詳述,至少五個分鏡;【配樂推薦】 :推薦這個影片要搭配的配樂風格並推薦幾個範例"}]) |
| | messages_base.extend([{"role": "user", "content": "請發揮你的創意跟想像並盡可能描述更多細節,必須要讓看到的人有驚豔的感覺。請使用繁體中文。"}]) |
| |
|
| | if content_type == 4: |
| | messages_base.extend([{"role": "user", "content": f"這是我之前請你產生的 Instagram user-generated campaign idea . Visualize how users can engage and share their experiences related to the product. "}]) |
| | messages_base.extend([{"role": "user", "content": f"接下來,請你根據之前生成的 {context} ,想像一個campaign的示意畫面,並給我DALLE AI繪圖用來生成這個畫面的Prompt,請用realistic photo的風格。"}]) |
| |
|
| | if content_type == 5: |
| | messages_base.extend([{"role": "user", "content": f"這是我之前請你產生的 Headlines. Visualize how users can engage and share their experiences related to the product. "}]) |
| | messages_base.extend([{"role": "user", "content": f"接下來,請你根據之前生成的 {context} ,想像三個campaign的示意畫面,並給我DALLE AI繪圖用來生成這個畫面的Prompt,請用realistic photo的風格。"}]) |
| |
|
| |
|
| | full_text = "" |
| | total_price = 0 |
| |
|
| |
|
| | |
| | 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 |
| |
|
| |
|
| | price = total_prompt_tokens_used*0.005/1000 + total_completion_tokens_used*0.015/1000 |
| | price_str = "price:" + str(price) + "$" |
| |
|
| | full_text += "\n\n" + price_str |
| |
|
| |
|
| | |
| | return full_text |