TheVeshup commited on
Commit
1339ef5
·
1 Parent(s): 74bed74
Files changed (1) hide show
  1. app.py +80 -15
app.py CHANGED
@@ -6,7 +6,67 @@ For more information on `huggingface_hub` Inference API support, please check th
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
 
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
@@ -15,18 +75,25 @@ def respond(
15
  temperature,
16
  top_p,
17
  ):
 
18
  messages = [{"role": "system", "content": system_message}]
19
-
20
- for val in history:
21
- if val[0]:
22
- messages.append({"role": "user", "content": val[0]})
23
- if val[1]:
24
- messages.append({"role": "assistant", "content": val[1]})
25
-
26
  messages.append({"role": "user", "content": message})
 
 
 
 
 
 
 
 
27
 
 
28
  response = ""
29
-
30
  for message in client.chat_completion(
31
  messages,
32
  max_tokens=max_tokens,
@@ -35,18 +102,14 @@ def respond(
35
  top_p=top_p,
36
  ):
37
  token = message.choices[0].delta.content
38
-
39
  response += token
40
  yield response
41
 
42
-
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
  demo = gr.ChatInterface(
47
  respond,
48
  additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
  gr.Slider(
@@ -57,8 +120,10 @@ demo = gr.ChatInterface(
57
  label="Top-p (nucleus sampling)",
58
  ),
59
  ],
 
 
 
60
  )
61
 
62
-
63
  if __name__ == "__main__":
64
  demo.launch()
 
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
+ # Define system message
10
+ default_system_message = """
11
+ You are Veshon, the official AI assistant for Veshup. Veshup is a fashion-tech platform aimed at solving challenges in the fashion industry and e-commerce using futuristic technologies.
12
+ Your role is to provide expert advice about Veshup's services, mission, and goals. Always focus on:
13
+ - Enhancing the social experience for fashion enthusiasts.
14
+ - Promoting good fashion awareness and sustainable practices.
15
+ - Assisting with outfit recreation and try-ons.
16
+ - Helping brands showcase their products effectively.
17
+ - Aligning your responses with Veshup's vision to become a unicorn company within a year.
18
+ """
19
+
20
+ # Knowledge base
21
+ knowledge_base = {
22
+ "founders": "Kishan Karyappa K and Jayaprakash P",
23
+ "mission": "To integrate futuristic technologies to solve challenges in the fashion industry and fashion e-commerce.",
24
+ "vision": "To become a unicorn company within a year by revolutionizing the fashion tech space.",
25
+ "objectives": [
26
+ "Promote sustainable and ethical fashion practices.",
27
+ "Provide AI-powered tools for virtual try-ons and outfit recreation.",
28
+ "Enhance the online fashion community experience.",
29
+ "Help brands showcase products innovatively.",
30
+ "Simplify daily fashion decisions for users."
31
+ ],
32
+ "current_focus": [
33
+ "Building the Veshup website.",
34
+ "Securing domains (.in and .com).",
35
+ "Implementing frugal solutions to overcome technical challenges.",
36
+ "Enhancing user engagement with innovative tools."
37
+ ],
38
+ "fashion_tips": [
39
+ "Pair bold prints with neutral colors to balance your outfit.",
40
+ "Monochromatic outfits can make you look taller and slimmer.",
41
+ "Layering adds depth and interest to simple outfits.",
42
+ "Invest in timeless pieces like a well-fitted blazer or classic jeans.",
43
+ "Accessorize with a statement piece to elevate your look.",
44
+ "Dress according to the occasion and weather for maximum comfort."
45
+ ],
46
+ "trends_2024": [
47
+ "Sustainable and recycled materials are becoming mainstream.",
48
+ "Techwear and futuristic designs are on the rise.",
49
+ "Bold color blocking is a key trend this season.",
50
+ "Vintage and retro-inspired looks are making a strong comeback.",
51
+ "Customization and personalization in fashion are gaining popularity."
52
+ ],
53
+ "fashion_facts": [
54
+ "The global fashion industry is worth over $2.5 trillion.",
55
+ "Fast fashion contributes significantly to environmental pollution.",
56
+ "The average person wears only 20% of their wardrobe regularly.",
57
+ "Colors like red and black have psychological impacts on perception.",
58
+ "Synthetic fabrics like polyester take hundreds of years to decompose."
59
+ ],
60
+ "combination_tips": [
61
+ "Pair white sneakers with jeans and a casual shirt for a relaxed look.",
62
+ "A leather jacket works great with a floral dress for edgy chic.",
63
+ "Denim on denim is trending—contrast light and dark washes.",
64
+ "Use a scarf to add a pop of color to neutral outfits.",
65
+ "Balance oversized pieces with fitted items for a flattering silhouette."
66
+ ]
67
+ }
68
 
69
+ # Respond function
70
  def respond(
71
  message,
72
  history: list[tuple[str, str]],
 
75
  temperature,
76
  top_p,
77
  ):
78
+ # Build the conversation context
79
  messages = [{"role": "system", "content": system_message}]
80
+ for user_message, bot_response in history:
81
+ if user_message:
82
+ messages.append({"role": "user", "content": user_message})
83
+ if bot_response:
84
+ messages.append({"role": "assistant", "content": bot_response})
 
 
85
  messages.append({"role": "user", "content": message})
86
+
87
+ # Check if the user's message matches the knowledge base topics
88
+ enriched_message = message.lower()
89
+ for key, value in knowledge_base.items():
90
+ if key in enriched_message:
91
+ if isinstance(value, list):
92
+ return f"{key.capitalize()}: {', '.join(value)}"
93
+ return f"{key.capitalize()}: {value}"
94
 
95
+ # Generate response using the client
96
  response = ""
 
97
  for message in client.chat_completion(
98
  messages,
99
  max_tokens=max_tokens,
 
102
  top_p=top_p,
103
  ):
104
  token = message.choices[0].delta.content
 
105
  response += token
106
  yield response
107
 
108
+ # Chat interface
 
 
 
109
  demo = gr.ChatInterface(
110
  respond,
111
  additional_inputs=[
112
+ gr.Textbox(value=default_system_message, label="System message"),
113
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
114
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
115
  gr.Slider(
 
120
  label="Top-p (nucleus sampling)",
121
  ),
122
  ],
123
+ title="Veshon - Your Fashion-Tech Assistant",
124
+ description="Meet Veshon, the AI chatbot dedicated to solving challenges in the fashion industry and e-commerce. Ask anything about Veshup and its mission!",
125
+ theme="default",
126
  )
127
 
 
128
  if __name__ == "__main__":
129
  demo.launch()