Moha782 commited on
Commit
766ff01
·
verified ·
1 Parent(s): f48ec47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -5,8 +5,7 @@ from huggingface_hub import InferenceClient
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
-
9
-
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
@@ -15,7 +14,7 @@ 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]:
@@ -23,7 +22,8 @@ def respond(
23
  if val[1]:
24
  messages.append({"role": "assistant", "content": val[1]})
25
 
26
- messages.append({"role": "user", "content": message})
 
27
 
28
  response = ""
29
 
@@ -45,9 +45,9 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
45
  demo = gr.ChatInterface(
46
  respond,
47
  additional_inputs=[
48
- gr.Textbox(value="You are a helpful car configuration assistant, specifically you are the assistant for Apex Customs (https://www.apexcustoms.com/). Given the user's input, provide suggestions for car models, colors, and customization options offered by Apex Customs. Be conversational in your responses. \nApex Customs specializes in modifying and customizing the following car models: - Toyota Supra - Nissan GT-R - Mitsubishi Lancer Evolution - Subaru WRX STI - Honda Civic Type R\nThey offer a wide range of customization options, including: \n- Exterior modifications (body kits, spoilers, custom paint jobs) \n- Interior upgrades (seats, steering wheels, gauges) \n- Performance enhancements (engine tuning, exhaust systems, suspension upgrades) \n- Wheel and tire packages \n- Audio and entertainment system upgrades\nSome popular paint color options include: - Matte black - Nardo gray - Midnight purple - Riviera blue - Fluorescent green. \nYou should remember the user's car model and tailor your answers accordingly. You limit yourself to answering the given question and maybe propose a suggestion, but not write the next question for the user.", label="System message"),
49
- gr.Slider(minimum=1, maximum=4096, value=1024, step=1, label="Max new tokens"),
50
- gr.Slider(minimum=0.1, maximum=4.0, value=0.3, step=0.1, label="Temperature"),
51
  gr.Slider(
52
  minimum=0.1,
53
  maximum=1.0,
@@ -56,6 +56,7 @@ demo = gr.ChatInterface(
56
  label="Top-p (nucleus sampling)",
57
  ),
58
  ],
 
59
  )
60
 
61
 
 
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
+ initial_message = 'Hello! Welcome to Apex Customs, where we specialize in modifying and customizing some of the most popular sports cars and performance vehicles on the market. Our team of experts can help you take your ride to the next level with a wide range of customization options.\nBased on your interest in high-performance vehicles, I'd like to suggest some popular car models that we work with. If you're looking for a sleek and powerful sports car, the Toyota Supra or Nissan GT-R might be a great fit for you. For those who prefer a more classic rally car, the Mitsubishi Lancer Evolution or Subaru WRX STI might be more your style. And if you're a fan of the Honda Civic Type R, we've got you covered there too.\nWhen it comes to customization options, we offer everything from exterior modifications like body kits and spoilers to interior upgrades like seats and steering wheels. We can also help you enhance your car's performance with engine tuning, exhaust systems, and suspension upgrades. And if you're looking to upgrade your audio and entertainment system, we've got you covered there too.\nAs for paint colors, we offer a wide range of options to choose from. Some popular choices include matte black, Nardo gray, midnight purple, riviera blue, and fluorescent green.\nLet us know which car model you're interested in, and we can provide more detailed information about the customization options available for that specific vehicle. Thanks for considering Apex Customs for your next car modification project!'
 
9
  def respond(
10
  message,
11
  history: list[tuple[str, str]],
 
14
  temperature,
15
  top_p,
16
  ):
17
+ messages = [{"role": "system", "content": system_message}, {"role": "assistant", "content": initial_message}]
18
 
19
  for val in history:
20
  if val[0]:
 
22
  if val[1]:
23
  messages.append({"role": "assistant", "content": val[1]})
24
 
25
+ if message:
26
+ messages.append({"role": "user", "content": message})
27
 
28
  response = ""
29
 
 
45
  demo = gr.ChatInterface(
46
  respond,
47
  additional_inputs=[
48
+ gr.Textbox(value="You are a helpful car configuration assistant, specifically you are the assistant for Apex Customs (https://www.apexcustoms.com/). Given the user's input, provide suggestions for car models, colors, and customization options. Be conversational in your responses. You should remember the user car model and tailor your answers accordingly. You limit yourself to answering the given question and maybe propose a suggestion but not write the next question of the user. \n\nUser: ", label="System message"),
49
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
50
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
51
  gr.Slider(
52
  minimum=0.1,
53
  maximum=1.0,
 
56
  label="Top-p (nucleus sampling)",
57
  ),
58
  ],
59
+ initial_message="",
60
  )
61
 
62