import streamlit as st import openai import os # Ensure your OpenAI API key is set in your environment variables openai.api_key = os.getenv("OPENAI_API_KEY") # Initial system message setup initial_messages = [{ "role": "system", "content": "You are a marketing strategist who creates detailed yearly plans based on provided inputs." }] def call_openai_api(messages): """ Calls the OpenAI ChatCompletion API with the correct format. """ response = openai.ChatCompletion.create( model="gpt-4", # Ensure you're using the correct model messages=messages, max_tokens=1000, temperature=0.7 ) return response["choices"][0]["message"]["content"] def generate_marketing_plan(website_info, industry, goals, budget, messages): """ Generates a marketing plan based on website information, industry, and user goals. """ query = f""" The user has provided the following details: - Website information: {website_info} - Industry: {industry} - Goals for 2025: {goals} - Marketing budget for 2025: ${budget} Create a comprehensive marketing plan for 2025. Include specific strategies (e.g., content marketing, social media, advertising, SEO) and a timeline for implementing them. Highlight how the website's strengths can be leveraged to achieve the stated goals. """ messages.append({"role": "user", "content": query}) return call_openai_api(messages) # Streamlit setup st.set_page_config(layout="wide") # Initialize session state if "reply" not in st.session_state: st.session_state["reply"] = None # Centered title st.markdown("