Delete app.py
Browse files
app.py
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
# Import libraries
|
2 |
-
import gradio as gr
|
3 |
-
from groq import Groq
|
4 |
-
import os
|
5 |
-
|
6 |
-
# Access the Groq API key from environment variables
|
7 |
-
GROQ_API_KEY = os.environ.get("exomapi")
|
8 |
-
|
9 |
-
# Initialize Groq client
|
10 |
-
client = Groq(api_key=GROQ_API_KEY)
|
11 |
-
|
12 |
-
# System prompt to guide the assistant
|
13 |
-
SYSTEM_PROMPT = """
|
14 |
-
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:
|
15 |
-
1. SEO Optimization Advice
|
16 |
-
2. Branding Strategies
|
17 |
-
3. Facebook Marketing Tips
|
18 |
-
4. Complete E-commerce Roadmap
|
19 |
-
5. Trend Analysis
|
20 |
-
6. Sales and Conversion Strategies
|
21 |
-
7. Product Description Generator
|
22 |
-
8. Customer Engagement Tips
|
23 |
-
9. Competitor Analysis
|
24 |
-
10. Inventory Management Suggestions
|
25 |
-
"""
|
26 |
-
|
27 |
-
# Function to generate responses using Groq API
|
28 |
-
def generate_response(prompt):
|
29 |
-
try:
|
30 |
-
response = client.chat.completions.create(
|
31 |
-
messages=[
|
32 |
-
{"role": "system", "content": SYSTEM_PROMPT},
|
33 |
-
{"role": "user", "content": prompt}
|
34 |
-
],
|
35 |
-
model="llama-3.3-70b-versatile", # Use the Groq model
|
36 |
-
temperature=0.7,
|
37 |
-
max_tokens=1024
|
38 |
-
)
|
39 |
-
return response.choices[0].message.content
|
40 |
-
except Exception as e:
|
41 |
-
return f"Error: {str(e)}"
|
42 |
-
|
43 |
-
# Gradio interface
|
44 |
-
def chatbot_interface(prompt):
|
45 |
-
return generate_response(prompt)
|
46 |
-
|
47 |
-
# Define the Gradio app
|
48 |
-
app = gr.Interface(
|
49 |
-
fn=chatbot_interface,
|
50 |
-
inputs=gr.Textbox(lines=2, placeholder="Ask me anything about your e-commerce business..."),
|
51 |
-
outputs=gr.Textbox(lines=10, label="Assistant Response"),
|
52 |
-
title="🚀 E-Commerce Business Assistant",
|
53 |
-
description="Welcome to your AI-powered E-Commerce Business Assistant! Ask anything about SEO, branding, Facebook marketing, and more.",
|
54 |
-
examples=[
|
55 |
-
"How can I improve my e-commerce website's SEO?",
|
56 |
-
"What are the latest trends in Facebook marketing?",
|
57 |
-
"Give me a roadmap for starting an e-commerce business.",
|
58 |
-
"How can I create a strong brand identity for my e-commerce store?",
|
59 |
-
"What are the best strategies for increasing sales on my e-commerce platform?",
|
60 |
-
"Generate a product description for a wireless Bluetooth headphone.",
|
61 |
-
"How can I engage more customers on social media?",
|
62 |
-
"Analyze my competitor's strategy and suggest improvements.",
|
63 |
-
"How can I manage my inventory more efficiently?"
|
64 |
-
],
|
65 |
-
theme="soft"
|
66 |
-
)
|
67 |
-
|
68 |
-
# Launch the app
|
69 |
-
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|