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 system message setup for the emoji adder initial_messages = [{ "role": "system", "content": """ You are an assistant that adds appropriate emojis to a given text. Analyze the content for tone, context, and meaning, and then insert emojis in a way that enhances the message without overwhelming it. The style of emoji usage will depend on the user's preferences for tone, density, and placement. """ }] def call_openai_api(messages): return openai.ChatCompletion.create( model="gpt-4", messages=messages, max_tokens=500 # Adjust based on the expected length of emoji-enhanced output ) def CustomChatGPT(text, tone, density, placement, messages): query = f""" Enhance the following text by adding emojis based on these preferences: - Tone: {tone} - Density: {density} - Placement: {placement} Text: {text} """ 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("