TogetherAI commited on
Commit
4f85d27
·
1 Parent(s): 6966d0f

Update app_template.py

Browse files
Files changed (1) hide show
  1. app_template.py +18 -7
app_template.py CHANGED
@@ -11,11 +11,11 @@ def build_input_prompt(message, chatbot, system_prompt):
11
  """
12
  Constructs the input prompt string from the chatbot interactions and the current message.
13
  """
14
- input_prompt = "<|system|>\n" + system_prompt + "</s>\n<|user|>\n"
15
  for interaction in chatbot:
16
- input_prompt = input_prompt + str(interaction[0]) + "</s>\n<|assistant|>\n" + str(interaction[1]) + "\n</s>\n<|user|>\n"
17
 
18
- input_prompt = input_prompt + str(message) + "</s>\n<|assistant|>"
19
  return input_prompt
20
 
21
 
@@ -55,20 +55,31 @@ def predict_beta(message, chatbot=[], system_prompt=""):
55
 
56
  def test_preview_chatbot(message, history):
57
  response = predict_beta(message, history, SYSTEM_PROMPT)
58
- text_start = response.rfind("<|assistant|>", ) + len("<|assistant|>")
59
  response = response[text_start:]
60
  return response
61
 
62
 
 
 
 
 
 
 
 
 
63
  welcome_preview_message = f"""
64
  Welcome to **{TITLE}**! Say something like:
65
-
66
  "{EXAMPLE_INPUT}"
67
  """
68
 
69
  chatbot_preview = gr.Chatbot(layout="panel", value=[(None, welcome_preview_message)])
70
  textbox_preview = gr.Textbox(scale=7, container=False, value=EXAMPLE_INPUT)
71
 
72
- demo = gr.ChatInterface(test_preview_chatbot, chatbot=chatbot_preview, textbox=textbox_preview)
 
 
 
 
73
 
74
- demo.launch()
 
11
  """
12
  Constructs the input prompt string from the chatbot interactions and the current message.
13
  """
14
+ input_prompt = "\n" + system_prompt + "</s>\n\n"
15
  for interaction in chatbot:
16
+ input_prompt = input_prompt + str(interaction[0]) + "</s>\n\n" + str(interaction[1]) + "\n</s>\n\n"
17
 
18
+ input_prompt = input_prompt + str(message) + "</s>\n"
19
  return input_prompt
20
 
21
 
 
55
 
56
  def test_preview_chatbot(message, history):
57
  response = predict_beta(message, history, SYSTEM_PROMPT)
58
+ text_start = response.rfind("", ) + len("")
59
  response = response[text_start:]
60
  return response
61
 
62
 
63
+ # Define your custom CSS here
64
+ css = """
65
+ /* Add your custom CSS styles here */
66
+ """
67
+
68
+ # Define your theme here
69
+ theme = "ParityError/Interstellar"
70
+
71
  welcome_preview_message = f"""
72
  Welcome to **{TITLE}**! Say something like:
 
73
  "{EXAMPLE_INPUT}"
74
  """
75
 
76
  chatbot_preview = gr.Chatbot(layout="panel", value=[(None, welcome_preview_message)])
77
  textbox_preview = gr.Textbox(scale=7, container=False, value=EXAMPLE_INPUT)
78
 
79
+ # Modify this part to include your theme and CSS
80
+ with gr.Blocks(css=css, theme=theme) as demo:
81
+ demo.add_component(chatbot_preview)
82
+ demo.add_component(textbox_preview)
83
+ demo.add_component(gr.Button("Submit"))
84
 
85
+ demo.launch()