import streamlit as st import openai import requests from bs4 import BeautifulSoup import os # Ensure your OpenAI API key is set in your environment variables openai.api_key = os.environ["OPENAI_API_KEY"] def scrape_website(url): """ Scrapes the given website URL to extract business-related information. """ try: response = requests.get(url) response.raise_for_status() soup = BeautifulSoup(response.content, "html.parser") # Extract meta description or a paragraph as a summary description = soup.find("meta", {"name": "description"}) or soup.find("p") return description.get("content") if description else "No description found." except Exception as e: return f"Error fetching website data: {e}" def call_openai_api(messages): """ Calls the OpenAI API using the updated interface for synchronous requests. """ response = openai.ChatCompletion.create( model="gpt-4", # Replace with "openai-o1" or your desired model messages=messages, max_tokens=1000 ) return response 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} Please 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}) response = call_openai_api(messages) ChatGPT_reply = response["choices"][0]["message"]["content"] messages.append({"role": "assistant", "content": ChatGPT_reply}) return ChatGPT_reply, 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("