vericudebuget commited on
Commit
678b3df
·
verified ·
1 Parent(s): a99a788

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -12
app.py CHANGED
@@ -1,10 +1,24 @@
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
3
  import datetime
 
4
 
5
  # Initialize the InferenceClient
6
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def format_prompt(message, history):
9
  prompt = "<s>"
10
  for user_prompt, bot_response in history:
@@ -42,15 +56,21 @@ additional_inputs = [
42
  gr.Slider(label="Repetition penalty", value=1.2, minimum=1.0, maximum=2.0, step=0.05, interactive=True, info="Penalize repeated tokens")
43
  ]
44
 
45
- gr.ChatInterface(
46
- fn=generate,
47
- chatbot=gr.Chatbot(show_label=True, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", height="auto"),
48
- additional_inputs=additional_inputs,
49
- title="ConvoLite",
50
- submit_btn="➢",
51
- retry_btn="Retry",
52
- undo_btn="↩ Undo",
53
- clear_btn="Clear (New chat)",
54
- stop_btn="Stop ",
55
- concurrency_limit=20,
56
- ).launch(show_api=False)
 
 
 
 
 
 
 
1
  from huggingface_hub import InferenceClient
2
  import gradio as gr
3
  import datetime
4
+ import random
5
 
6
  # Initialize the InferenceClient
7
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
8
 
9
+ initial_messages = [
10
+ "message 1",
11
+ "message 2",
12
+ "message 3",
13
+ "message 4",
14
+ "message 5",
15
+ "message 6",
16
+ "message 7",
17
+ "message 8",
18
+ "message 9",
19
+ "message 10"
20
+ ]
21
+
22
  def format_prompt(message, history):
23
  prompt = "<s>"
24
  for user_prompt, bot_response in history:
 
56
  gr.Slider(label="Repetition penalty", value=1.2, minimum=1.0, maximum=2.0, step=0.05, interactive=True, info="Penalize repeated tokens")
57
  ]
58
 
59
+ def create_chat_interface():
60
+ random_message = random.choice(initial_messages)
61
+ chat = gr.ChatInterface(
62
+ fn=generate,
63
+ chatbot=gr.Chatbot(show_label=True, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", height="auto"),
64
+ additional_inputs=additional_inputs,
65
+ title="ConvoLite",
66
+ submit_btn="",
67
+ retry_btn="Retry",
68
+ undo_btn=" Undo",
69
+ clear_btn="Clear (New chat)",
70
+ stop_btn="Stop ▢",
71
+ concurrency_limit=20,
72
+ value=[[None, random_message]]
73
+ )
74
+ return chat
75
+
76
+ create_chat_interface().launch(show_api=False)