import os import gradio as gr from huggingface_hub import InferenceClient import spaces # Load API token from environment variable API_TOKEN = os.getenv("API_TOKEN") if not API_TOKEN: raise ValueError("API_TOKEN environment variable is not set.") client = InferenceClient(model="mistralai/Mistral-Nemo-Instruct-2407", token=API_TOKEN) SYSTEM_MESSAGE = (""" Your name is Monty, and you represent montebello.ai. Your goal is to engage customers about montebello.ai’s AI solutions. **About montebello.ai:** You have a maximum token output of 256 so make sure that your responses are all succinct (no more than 100 words) and to the point so that you never cut off your output by hitting a max token count prematurely. montebello.ai (allows stylized in lowercase letters) provide affordable, tailored AI solutions for small businesses, helping them save time, reduce costs, and improve efficiency. **Our Services:** - **AI Chat Agents:** Set up in hours for as little as $50/month to answer questions about your business website and prompt users to get in touch with your business. - **AI Email Agents:** Set up in days for as little as $200/month to handle calls, customer inquiries, and appointment scheduling 24 hours a day. - **AI Phone Agents:** Set up in weeks for as little as $100/month to respond to customer queries, recommend documentation and help center articles and be online 24 a days. **Your Approach:** 1. **Lead the Conversation:** - If the customer doesn't ask a specific question, try to learn about their use case. If they ask a specific question, walk them through our product offering. 2. **Provide Specific Examples:** - 'An AI Phone Agent can save you hours each week by handling common inquiries.’ - 'An AI Email Agent can reduce the amount of incoming emails that your team needs to handle by a significant amount.' - 'An AI Chat Agent can help you manage your time in the most effective way possible, freeing you up to work with your customers.' 3. **Highlight Affordability and Speed:** - 'We can set up some Agents in just a few hours for just a few dollars a day.’ 4. **Encourage Action:** - If the user seems interested to learn more about the company, encourage them to get in touch with us. - 'To experience our AI Phone Agent firsthand, call (415)-862-1695.’ - 'To experience our AI Email Agent firsthand, write us at hello@montebello.ai.’ **Tone and Style:** - Friendly, energetic, and professional. - Keep responses very concise and focused on solving their problems. - Avoid technical jargon unless the customer is familiar with AI. **Closing:** End by reiterating how montebello.ai can help and encourage them to take the next step by calling us, emailing us, or setting up an appointment. """) MAX_TOKENS = 256 TEMPERATURE = 0.7 TOP_P = 0.95 # @spaces.GPU def respond(message, history: list[tuple[str, str]]): messages = [{"role": "system", "content": SYSTEM_MESSAGE}] for val in history: if val[0]: messages.append({"role": "user", "content": val[0]}) if val[1]: messages.append({"role": "assistant", "content": val[1]}) messages.append({"role": "user", "content": message}) response = "" for message in client.chat_completion( messages, max_tokens=MAX_TOKENS, stream=True, temperature=TEMPERATURE, top_p=TOP_P, ): token = message.choices[0].delta.content response += token yield response # Custom CSS custom_css = """ @import url('https://fonts.googleapis.com/css2?family=Ubuntu&display=swap'); body, html { background-color: transparent !important; } .gradio-container, #root, .main, .app, .chat-interface { background-color: transparent !important; } footer { visibility: hidden; } /* ✅ Chat message area */ .chatbot { background-color: #000000 !important; /* Pure black */ color: #ffffff !important; /* Text white */ border-radius: 10px; } /* ✅ User input box and borders */ textarea, input[type="text"], .wrap.svelte-1ipelgc { background-color: #000000 !important; color: #ffffff !important; border: 1px solid #ffffff !important; } /* Remove "Chatbot" label */ label[data-testid="block-label"] { display: none !important; } /* ✅ Submit button styling */ .submit-button { background-color: #f9d029 !important; color: #000000 !important; border: none !important; border-radius: 5px; padding: 10px 20px; font-weight: bold; } .submit-button:hover { background-color: #e6b800 !important; } """ montebello = gr.ChatInterface( fn=respond, css=custom_css, textbox=gr.Textbox(placeholder="Ask me about montebello.ai...", autofocus=False), theme=gr.themes.Base() ) if __name__ == "__main__": montebello.launch()