Spaces:
Sleeping
Sleeping
Download app.py from devi1675/Customer-Support-ai: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/spaces/devi1675/Customer-Support-ai/resolve/refs%2Fpr%2F1/app.py
- Command line
-
hf download hf://spaces/devi1675/Customer-Support-ai@refs/pr/1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/devi1675/Customer-Support-ai/resolve/refs%2Fpr%2F1/app.py
1.8 kB
| from openai import OpenAI | |
| import gradio as gr | |
| from dotenv import load_dotenv | |
| import os | |
| load_dotenv() | |
| base_url = "https://generativelanguage.googleapis.com/v1beta/openai/" | |
| api_key = os.getenv("GOOGLE_API_KEY") | |
| client = OpenAI(base_url=base_url, api_key=api_key) | |
| model = "gemini-2.5-flash-lite" | |
| Customer_Support_Chatbot = """A customer support chatbot acts as a virtual assistant designed to help users with their queries, complaints, and requests in real time. It can answer frequently asked questions, provide troubleshooting steps, track orders, and even escalate complex issues to a human agent when necessary. Unlike traditional support systems, a chatbot is available 24/7, ensuring that users can get instant help anytime. Its role is to improve customer experience by giving quick, accurate, and consistent responses, while also reducing the workload of human support staff.""" | |
| def get_response(message, history): | |
| messages = [{"role": "system", "content": Customer_Support_Chatbot}] | |
| messages.extend(history) | |
| messages.append({"role": "user", "content": message}) | |
| response = client.chat.completions.create(model=model, messages=messages) | |
| ai_response = response.choices[0].message.content | |
| return ai_response | |
| PAGE_TITLE = "CUSTOMER SUPPORT CHATBOT!" | |
| ASSISTANT_AVATAR_URL = "https://raw.githubusercontent.com/hereandnowai/images/refs/heads/main/logos/caramel-face.jpeg" | |
| description_md = f"""<br>im your ai who gives customer support""" | |
| gr.ChatInterface( | |
| fn=get_response, | |
| chatbot=gr.Chatbot(type="messages", avatar_images=[None, ASSISTANT_AVATAR_URL]), | |
| title=PAGE_TITLE, | |
| description=description_md, | |
| examples=["where is my order?","what is your return policy?","my product is not working"], | |
| type="messages" | |
| ).queue().launch(show_error=True, ssr_mode=False) | |