MaxLSB commited on
Commit
52a9a97
·
verified ·
1 Parent(s): 39c555f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -18
app.py CHANGED
@@ -71,27 +71,54 @@ def respond(
71
  yield accumulated
72
 
73
  # Create Gradio Chat Interface
74
- demo = gr.ChatInterface(
75
- fn=respond,
76
- additional_inputs=[
77
- gr.Dropdown(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  choices=["LeCarnet-3M", "LeCarnet-8M", "LeCarnet-21M"],
79
  value="LeCarnet-8M",
80
  label="Model",
81
- ),
82
- gr.Slider(1, 512, value=512, step=1, label="Max New Tokens"),
83
- gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature"),
84
- gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p"),
85
- ],
86
- title="LeCarnet",
87
- description="Select a model and enter text to get started.",
88
- examples=[
89
- ["Il était une fois un petit garçon qui vivait dans un village paisible."],
90
- ["Il était une fois une grenouille qui rêvait de toucher les étoiles chaque nuit depuis son étang."],
91
- ["Il était une fois un petit lapin perdu"],
92
- ],
93
- cache_examples=False,
94
- )
 
 
 
95
 
 
96
  if __name__ == "__main__":
97
  demo.queue(default_concurrency_limit=10, max_size=10).launch(ssr_mode=False, max_threads=10)
 
71
  yield accumulated
72
 
73
  # Create Gradio Chat Interface
74
+ with gr.Blocks() as demo:
75
+ # Custom title with logo
76
+ with gr.Row():
77
+ gr.HTML(
78
+ '<div style="display: flex; align-items: center;">'
79
+ f'<img src="file/{os.path.abspath("media/le-carnet.png")}" style="height: 50px; margin-right: 10px;" />'
80
+ '<h1 style="margin: 0;">LeCarnet</h1>'
81
+ '</div>'
82
+ )
83
+
84
+ # Chat interface
85
+ chatbot = gr.ChatInterface(
86
+ fn=respond,
87
+ title=None, # Remove default title
88
+ description=None, # Remove default description
89
+ examples=[
90
+ ["Il était une fois un petit garçon qui vivait dans un village paisible."],
91
+ ["Il était une fois une grenouille qui rêvait de toucher les étoiles chaque nuit depuis son étang."],
92
+ ["Il était une fois un petit lapin perdu"],
93
+ ],
94
+ cache_examples=False,
95
+ )
96
+
97
+ # Sidebar for model selection and parameters
98
+ with gr.Column(elem_classes="sidebar", variant="panel"):
99
+ gr.Markdown("### Model Configuration")
100
+ model_dropdown = gr.Dropdown(
101
  choices=["LeCarnet-3M", "LeCarnet-8M", "LeCarnet-21M"],
102
  value="LeCarnet-8M",
103
  label="Model",
104
+ )
105
+ max_tokens_slider = gr.Slider(1, 512, value=512, step=1, label="Max New Tokens")
106
+ temperature_slider = gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature")
107
+ top_p_slider = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
108
+
109
+ # Pass parameters to the chatbot
110
+ chatbot.load(
111
+ fn=lambda x, y, z, w: None,
112
+ inputs=[model_dropdown, max_tokens_slider, temperature_slider, top_p_slider],
113
+ outputs=None,
114
+ )
115
+ chatbot.config.update({
116
+ "model_name": model_dropdown,
117
+ "max_tokens": max_tokens_slider,
118
+ "temperature": temperature_slider,
119
+ "top_p": top_p_slider,
120
+ })
121
 
122
+ # Launch the app
123
  if __name__ == "__main__":
124
  demo.queue(default_concurrency_limit=10, max_size=10).launch(ssr_mode=False, max_threads=10)