prithivMLmods commited on
Commit
aef7a3d
1 Parent(s): 48b9513

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -38
app.py CHANGED
@@ -71,7 +71,7 @@ mood_prompts = {
71
 
72
  def respond(
73
  message,
74
- history,
75
  system_message,
76
  max_tokens,
77
  temperature,
@@ -107,42 +107,27 @@ def respond(
107
  response += token
108
  yield response
109
 
110
- # Define the layout
111
- def create_interface():
112
- with gr.Blocks(css=css, theme="allenai/gradio-theme") as demo:
113
- gr.Markdown("# Chat Interface")
114
-
115
- with gr.Row():
116
- with gr.Column():
117
- message_input = gr.Textbox(placeholder="Type your message here...", label="Message")
118
- history_input = gr.Textbox(placeholder="Chat history (if any)...", label="History")
119
- system_message_input = gr.Textbox(value="", label="System message")
120
- max_tokens_slider = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
121
- temperature_slider = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
122
- top_p_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-P")
123
-
124
- with gr.Row():
125
- mood_dropdown = gr.Dropdown(
126
- choices=list(mood_prompts.keys()),
127
- label="Mood",
128
- value="Casual"
129
- )
130
-
131
- chat_interface = gr.Interface(
132
- fn=respond,
133
- inputs=[
134
- message_input,
135
- history_input,
136
- system_message_input,
137
- max_tokens_slider,
138
- temperature_slider,
139
- top_p_slider,
140
- mood_dropdown
141
- ],
142
- outputs=gr.Textbox(label="Response")
143
  )
144
-
145
- chat_interface.launch()
146
-
 
147
  if __name__ == "__main__":
148
- create_interface()
 
71
 
72
  def respond(
73
  message,
74
+ history: list[tuple[str, str]],
75
  system_message,
76
  max_tokens,
77
  temperature,
 
107
  response += token
108
  yield response
109
 
110
+ demo = gr.ChatInterface(
111
+ respond,
112
+ additional_inputs=[
113
+ gr.Textbox(value="", label="System message"),
114
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
115
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
116
+ gr.Slider(
117
+ minimum=0.1,
118
+ maximum=1.0,
119
+ value=0.95,
120
+ step=0.05,
121
+ label="Top-P",
122
+ ),
123
+ gr.Dropdown(
124
+ choices=list(mood_prompts.keys()),
125
+ label="Mood",
126
+ value="Casual"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  )
128
+ ],
129
+ css=css,
130
+ theme="allenai/gradio-theme",
131
+ )
132
  if __name__ == "__main__":
133
+ demo.launch()