heffnt commited on
Commit
0c6cc3d
·
1 Parent(s): c0b3a22

Refactor chatbot implementation in app.py to use a custom chatbot with avatar images and add monster_icon.png asset.

Browse files
Files changed (2) hide show
  1. app.py +20 -13
  2. assets/monster_icon.png +3 -0
app.py CHANGED
@@ -141,24 +141,31 @@ def respond(
141
  yield response
142
 
143
 
144
- chatbot = gr.ChatInterface(
145
- fn=respond,
146
- additional_inputs=[
147
- gr.Textbox(value=DEFAULT_SYSTEM_MESSAGE, label="System message"),
148
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
149
- gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"),
150
- gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
151
- gr.Radio(choices=MODEL_OPTIONS, label="Select Model", value=MODEL_OPTIONS[2]),
152
- ],
153
- type="messages",
154
- )
155
-
156
  with gr.Blocks(css=fancy_css) as demo:
157
  with gr.Row():
158
  gr.LoginButton()
159
  with gr.Row():
160
  gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
161
- chatbot.render()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
  if __name__ == "__main__":
164
  demo.launch()
 
141
  yield response
142
 
143
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  with gr.Blocks(css=fancy_css) as demo:
145
  with gr.Row():
146
  gr.LoginButton()
147
  with gr.Row():
148
  gr.Markdown(f"<h1 style='text-align: center;'>{TITLE}</h1>")
149
+
150
+ # Create custom chatbot with avatar images
151
+ chatbot = gr.Chatbot(
152
+ type="messages",
153
+ avatar_images=(str(ASSETS_DIR / "monster_icon.png"), str(ASSETS_DIR / "smart_confidant_icon.png"))
154
+ )
155
+
156
+ # Create ChatInterface with the custom chatbot
157
+ gr.ChatInterface(
158
+ fn=respond,
159
+ chatbot=chatbot,
160
+ additional_inputs=[
161
+ gr.Textbox(value=DEFAULT_SYSTEM_MESSAGE, label="System message"),
162
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
163
+ gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"),
164
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
165
+ gr.Radio(choices=MODEL_OPTIONS, label="Select Model", value=MODEL_OPTIONS[2]),
166
+ ],
167
+ type="messages",
168
+ )
169
 
170
  if __name__ == "__main__":
171
  demo.launch()
assets/monster_icon.png ADDED

Git LFS Details

  • SHA256: 39fc86d8274065c584d941b6e808d333b8f1dd4146966d95499eb3a98cf60c43
  • Pointer size: 130 Bytes
  • Size of remote file: 52.8 kB