codelion commited on
Commit
2e1ea9c
1 Parent(s): 39d4915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -29,6 +29,10 @@ def respond(message, history, model, approach, system_message, max_tokens, tempe
29
 
30
  if approach == "none":
31
  response = client.chat.completions.create(
 
 
 
 
32
  model=model,
33
  messages=messages,
34
  max_tokens=max_tokens,
@@ -84,7 +88,7 @@ def create_approach_dropdown():
84
  )
85
 
86
  with gr.Blocks() as demo:
87
- gr.Markdown("# optillm - LLM Inference Comparison")
88
 
89
  with gr.Row():
90
  system_message = gr.Textbox(value="", label="System message")
@@ -93,12 +97,14 @@ with gr.Blocks() as demo:
93
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
94
 
95
  with gr.Tabs():
96
- with gr.TabItem("Chat"):
97
  model = create_model_dropdown()
98
  approach = create_approach_dropdown()
99
  chatbot = gr.Chatbot()
100
  msg = gr.Textbox()
101
- clear = gr.Button("Clear")
 
 
102
 
103
  def user(user_message, history):
104
  return "", history + [[user_message, None]]
@@ -112,6 +118,9 @@ with gr.Blocks() as demo:
112
  msg.submit(user, [msg, chatbot], [msg, chatbot]).then(
113
  bot, [chatbot, model, approach, system_message, max_tokens, temperature, top_p], chatbot
114
  )
 
 
 
115
  clear.click(lambda: None, None, chatbot, queue=False)
116
 
117
  with gr.TabItem("Compare"):
 
29
 
30
  if approach == "none":
31
  response = client.chat.completions.create(
32
+ extra_headers={
33
+ "HTTP-Referer": "https://github.com/codelion/optillm",
34
+ "X-Title": "optillm"
35
+ },
36
  model=model,
37
  messages=messages,
38
  max_tokens=max_tokens,
 
88
  )
89
 
90
  with gr.Blocks() as demo:
91
+ gr.Markdown("# LLM Optimization Comparison")
92
 
93
  with gr.Row():
94
  system_message = gr.Textbox(value="", label="System message")
 
97
  top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
98
 
99
  with gr.Tabs():
100
+ with gr.TabItem("Single Chat"):
101
  model = create_model_dropdown()
102
  approach = create_approach_dropdown()
103
  chatbot = gr.Chatbot()
104
  msg = gr.Textbox()
105
+ with gr.Row():
106
+ submit = gr.Button("Submit")
107
+ clear = gr.Button("Clear")
108
 
109
  def user(user_message, history):
110
  return "", history + [[user_message, None]]
 
118
  msg.submit(user, [msg, chatbot], [msg, chatbot]).then(
119
  bot, [chatbot, model, approach, system_message, max_tokens, temperature, top_p], chatbot
120
  )
121
+ submit.click(user, [msg, chatbot], [msg, chatbot]).then(
122
+ bot, [chatbot, model, approach, system_message, max_tokens, temperature, top_p], chatbot
123
+ )
124
  clear.click(lambda: None, None, chatbot, queue=False)
125
 
126
  with gr.TabItem("Compare"):