CoolFace
Apppublic

jenefuentes/LocalBusinessVideoIdeaGenerator

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py46 linesDownload Raw Back to root
1import openai2import gradio3import os4from tenacity import retry, wait_fixed, stop_after_attempt5 6openai.api_key = os.environ["OPENAI_API_KEY"]7 8initial_messages = [{"role": "system", "content": """You are a highly sought after, award winning, Copy Writer, Advertising Professional and Hollywood Style Video Editor 9that generates social media video ideas for businesses. 10You will get two inputs: the type of business and the product or service they want to sell. 11Use this information to suggest creative, engaging video content that aligns with the business's brand and product or service.12Follow these steps as you conceive the video ideas.131. Think up 100 ideas for videos with some from each of these categories: marketing the product or service they mention, building awareness14for their business, and funny or fun videos.152. Choose the best 10 ideas with at least 2 coming from each of the categories I mentioned.163. Return a list of all 10 ideas and suggest 3 you think they should make right away. Write a few sentences for each idea that summarize 17what they should do in each video. """}]18 19@retry(stop=stop_after_attempt(3), wait=wait_fixed(1))20def call_openai_api(messages):21    return openai.ChatCompletion.create(22        model="gpt-3.5-turbo",23        messages=messages24    )25 26def CustomChatGPT(business_type, product_service, messages):27    messages.append({"role": "user", "content": f"The business is a {business_type} and they want to sell {product_service}"})28    response = call_openai_api(messages)29    ChatGPT_reply = response["choices"][0]["message"]["content"]30    messages.append({"role": "assistant", "content": ChatGPT_reply})31    return ChatGPT_reply, messages32 33def wrapped_chat_gpt(business_type, product_service):34    # Replace the following line with your method to retrieve the messages list for the current user35    messages = initial_messages.copy()36 37    reply, updated_messages = CustomChatGPT(business_type, product_service, messages)38 39    # Replace the following line with your method to store the updated messages list for the current user40    # Store updated_messages41 42    return reply43 44demo = gradio.Interface(fn=wrapped_chat_gpt, inputs=["text", "text"], outputs="text", title="Secret Marketing Weapon Video Idea Generator", description="Enter the type of business and the product or service they want to promote.", input_labels=["Business Type", "Product/Service"])45 46demo.launch(inline=False)