| |
| import gradio as gr |
| from groq import Groq |
| import os |
|
|
| |
| GROQ_API_KEY = os.environ.get("exomapi") |
|
|
| |
| if not GROQ_API_KEY: |
| raise ValueError("The 'exomapi' environment variable is not set. Please set it in Hugging Face Spaces.") |
|
|
| |
| client = Groq(api_key=GROQ_API_KEY) |
|
|
| |
| SYSTEM_PROMPT = """ |
| You are an expert e-commerce business assistant. Your goal is to provide actionable advice on SEO, branding, Facebook marketing, and more. Be concise, professional, and creative in your responses. Always provide up-to-date information and trends. Your features include: |
| 1. SEO Optimization Advice |
| 2. Branding Strategies |
| 3. Facebook Marketing Tips |
| 4. Complete E-commerce Roadmap |
| 5. Trend Analysis |
| 6. Sales and Conversion Strategies |
| 7. Product Description Generator |
| 8. Customer Engagement Tips |
| 9. Competitor Analysis |
| 10. Inventory Management Suggestions |
| """ |
|
|
| |
| def generate_response(prompt): |
| try: |
| response = client.chat.completions.create( |
| messages=[ |
| {"role": "system", "content": SYSTEM_PROMPT}, |
| {"role": "user", "content": prompt} |
| ], |
| model="llama-3.3-70b-versatile", |
| temperature=0.7, |
| max_tokens=1024 |
| ) |
| return response.choices[0].message.content |
| except Exception as e: |
| return f"Error: {str(e)}" |
|
|
| |
| def chatbot_interface(prompt): |
| return generate_response(prompt) |
|
|
| |
| app = gr.Interface( |
| fn=chatbot_interface, |
| inputs=gr.Textbox(lines=2, placeholder="Ask me anything about your e-commerce business..."), |
| outputs=gr.Textbox(lines=10, label="Assistant Response"), |
| title="🚀 E-Commerce Business Assistant", |
| description="Welcome to your AI-powered E-Commerce Business Assistant! Ask anything about SEO, branding, Facebook marketing, and more.", |
| examples=[ |
| "How can I improve my e-commerce website's SEO?", |
| "What are the latest trends in Facebook marketing?", |
| "Give me a roadmap for starting an e-commerce business.", |
| "How can I create a strong brand identity for my e-commerce store?", |
| "What are the best strategies for increasing sales on my e-commerce platform?", |
| "Generate a product description for a wireless Bluetooth headphone.", |
| "How can I engage more customers on social media?", |
| "Analyze my competitor's strategy and suggest improvements.", |
| "How can I manage my inventory more efficiently?" |
| ], |
| theme="soft" |
| ) |
|
|
| |
| app.launch() |