import streamlit as st import openai import os # Ensure your OpenAI API key is set in your environment variables openai.api_key = os.environ["OPENAI_API_KEY"] initial_messages = [{ "role": "system", "content": """ Generate 100 video ideas tailored to the specified business type or industry. Some ideas should be for marketing videos, creative social media content, educational videos, and a few that are outside the box. Reply with the 10 best overall ideas, each with a short description (up to 2 sentences). """ }] def call_openai_api(messages): return openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=messages ) def CustomChatGPT(business_type, user_input, messages): query = f"Business type: {business_type}. {user_input}" if user_input else f"Business type: {business_type}. Generate general video ideas." messages.append({"role": "user", "content": query}) response = call_openai_api(messages) ChatGPT_reply = response["choices"][0]["message"]["content"] messages.append({"role": "assistant", "content": ChatGPT_reply}) return ChatGPT_reply, messages # Set layout to wide st.set_page_config(layout="wide") # Centered title st.markdown("

Video Idea Generator for Businesses

", unsafe_allow_html=True) # Create columns for input and output col1, col2 = st.columns(2) with col1: st.markdown("

Business Type & Topic

", unsafe_allow_html=True) business_type = st.text_input("Business Type", placeholder="Enter your business type (e.g., Real Estate, Retail, Health Care):") user_input = st.text_input("Topic (Optional)", placeholder="Enter a specific topic (optional):") generate_button = st.button('Generate Ideas') with col2: st.markdown("

Your Video Ideas ⬇️

", unsafe_allow_html=True) if generate_button: messages = initial_messages.copy() reply, _ = CustomChatGPT(business_type, user_input, messages) st.write(reply)