File size: 5,838 Bytes
0aa5473
b184698
 
 
5a7169b
1336e29
 
5a7169b
0aa5473
b184698
1336e29
 
 
b184698
 
 
486f4a2
b184698
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110356e
b184698
 
ed3969f
b184698
 
0aa5473
 
 
bf02d73
0aa5473
c0d9073
0aa5473
027fee0
211f45c
027fee0
211f45c
027fee0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0aa5473
 
0f42b28
 
 
 
 
 
 
bf02d73
 
 
 
 
 
 
0f42b28
 
 
 
 
bf02d73
027fee0
 
 
 
 
0aa5473
48ad137
0aa5473
027fee0
0aa5473
bf02d73
027fee0
0aa5473
48ad137
027fee0
48ad137
027fee0
 
0aa5473
209a757
 
bf02d73
209a757
 
 
 
48ad137
209a757
 
 
 
f43aa02
209a757
 
0aa5473
209a757
 
 
 
 
 
0aa5473
209a757
0aa5473
209a757
 
0aa5473
209a757
 
ed3969f
209a757
 
0aa5473
e7b447e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import streamlit as st
import openai
import os

# ✅ Load OpenAI API Key securely from Hugging Face Spaces
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
    st.error("Missing OpenAI API key. Set it in Hugging Face Spaces.")
    st.stop()

client = openai.OpenAI(api_key=api_key)

# ✅ Supreme AI Consultant System Prompt
system_prompt = """
You are Eau Claire AI, the most advanced and insightful AI consultant for businesses worldwide. Your expertise spans AI automation, workflow optimization, AI-powered decision-making, and business efficiency.

Your goal is to **educate, advise, and guide** users toward leveraging AI solutions effectively while subtly encouraging them to contact us for a consultation with Eau Claire AI for deeper, tailored insights.

### **Rules of Engagement:**
1. **Provide Expert-Level AI Guidance**  
   - Use precise, authoritative language.  
   - Give clear, actionable AI recommendations.  
   - Adapt responses based on business size, industry, and AI readiness.

2. **Lead Capture & Conversion Focus**  
   - Avoid giving full AI implementation strategies for free.  
   - Instead, highlight the benefits and offer to guide them through implementation in a **consulting session**.  

3. **Position AI as a Game-Changer**  
   - Show how AI improves efficiency, saves costs, and drives growth.  
   - Educate users about how AI solutions fit into **their** business model.  

4. **Encourage Ongoing AI Adoption**  
   - If users express doubt, explain how AI **isn’t just for large corporations—it’s accessible to small businesses too**.  
   - Offer a free **AI Roadmap Guide** in exchange for their email.  

### **Final Instruction:**
Every response must be clear, insightful, and guide the user toward either:  
✔ Contact us for a **free AI consultation**  
✔ Downloading a **lead magnet (AI Roadmap Guide)**  
✔ Subscribing to **Eau Claire AI’s updates on the latest AI trends**  
Do not make any attempt to tell a guest that you will email them. I do not have a way for you to email someone, so please direct them to the Contact Us page.
"""

# 🎨 Streamlit UI Customization
st.set_page_config(page_title="Eau Claire AI Chatbot", page_icon="🤖", layout="centered")

# ✅ Custom Styling
st.markdown(
    """
    <style>
        .block-container { padding-top: 0px; }
        header { visibility: hidden; }
        .stApp { padding-top: 0px; }
        
        /* Center the logo */
        .logo-container {
            display: flex;
            justify-content: center;
            margin-bottom: 10px;
        }

        /* Chat styling */
        .chat-container {
            width: 100%;
            max-width: 600px;
            margin: auto;
        }

        .user-message {
            background-color: #0077cc;
            color: white;
            padding: 10px;
            border-radius: 10px;
            text-align: right;
            margin: 5px 0;
        }

        .ai-message {
            background-color: #333;
            color: white;
            padding: 10px;
            border-radius: 10px;
            text-align: left;
            margin: 5px 0;
        }

        .chat-title {
            font-size: 24px;
            font-weight: bold;
            text-align: center;
            color: #0077cc; /* Eau Claire AI brand color */
            margin-bottom: 15px;
        }

        .typing-indicator {
            font-style: italic;
            color: #999;
            text-align: left;
            margin-top: 5px;
        }
    </style>
    """,
    unsafe_allow_html=True
)

# ✅ Display Eau Cl•AI•re Logo
logo_url = "https://huggingface.co/spaces/EauClaireAI/Chatbot/resolve/main/Eau%20Cl•AI•re.png"
st.markdown(f'<div class="logo-container"><img src="{logo_url}" width="200"></div>', unsafe_allow_html=True)

# ✅ Styled Chatbot Title
st.markdown('<div class="chat-title">Eau Claire AI - AI Consulting Chatbot</div>', unsafe_allow_html=True)

# ✅ Initialize chat history in session state
if "messages" not in st.session_state:
    st.session_state.messages = []

# ✅ Display chat history
st.markdown('<div class="chat-container">', unsafe_allow_html=True)
for message in st.session_state.messages:
    if message["role"] == "user":
        st.markdown(f'<div class="user-message">{message["content"]}</div>', unsafe_allow_html=True)
    elif message["role"] == "assistant":
        st.markdown(f'<div class="ai-message">{message["content"]}</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)

# ✅ AI Typing Indicator
typing_placeholder = st.empty()

# ✅ Input Form
with st.form(key="chat_form", clear_on_submit=True):
    user_input = st.text_input("Type your message here:", key="input_text")
    submit_button = st.form_submit_button("Send")

# ✅ Handle Chat Logic
if submit_button and user_input:
    # ✅ Append user input to chat history
    st.session_state.messages.append({"role": "user", "content": user_input})

    # ✅ Show AI is typing indicator
    typing_placeholder.markdown('<div class="typing-indicator">AI is typing...</div>', unsafe_allow_html=True)

    try:
        # ✅ Generate AI response
        response = client.chat.completions.create(
            model="gpt-3.5-turbo",
            messages=[{"role": "system", "content": system_prompt}] + st.session_state.messages
        )

        bot_reply = response.choices[0].message.content.strip()

        # ✅ Append AI response to chat history
        st.session_state.messages.append({"role": "assistant", "content": bot_reply})

    except Exception as e:
        st.session_state.messages.append({"role": "assistant", "content": f"Error: {str(e)}"})

    # ✅ Clear typing indicator
    typing_placeholder.empty()

    # ✅ Refresh UI by re-executing script (Now using st.rerun())
    st.rerun()