@@ -188,6 +188,7 @@ def sidebar(
188188 width : int = 400 ,
189189 height : str = "100%" ,
190190 fillable : bool = True ,
191+ id : Optional [str ] = None ,
191192 ** kwargs ,
192193 ) -> ui .Sidebar :
193194 """
@@ -201,6 +202,9 @@ def sidebar(
201202 Height of the sidebar.
202203 fillable
203204 Whether the sidebar should be fillable. Default is `True`.
205+ id
206+ Optional ID for the QueryChat instance. If not provided,
207+ will use the ID provided at initialization.
204208 **kwargs
205209 Additional arguments passed to `shiny.ui.sidebar()`.
206210
@@ -211,20 +215,23 @@ def sidebar(
211215
212216 """
213217 return ui .sidebar (
214- self .ui (),
218+ self .ui (id = id ),
215219 width = width ,
216220 height = height ,
217221 fillable = fillable ,
218222 class_ = "querychat-sidebar" ,
219223 ** kwargs ,
220224 )
221225
222- def ui (self , ** kwargs ):
226+ def ui (self , * , id : Optional [ str ] = None , * *kwargs ):
223227 """
224228 Create the UI for the querychat component.
225229
226230 Parameters
227231 ----------
232+ id
233+ Optional ID for the QueryChat instance. If not provided,
234+ will use the ID provided at initialization.
228235 **kwargs
229236 Additional arguments to pass to `shinychat.chat_ui()`.
230237
@@ -234,7 +241,7 @@ def ui(self, **kwargs):
234241 A UI component.
235242
236243 """
237- return mod_ui (self .id , ** kwargs )
244+ return mod_ui (id or self .id , ** kwargs )
238245
239246 def generate_greeting (self , * , echo : Literal ["none" , "output" ] = "none" ):
240247 """
@@ -561,7 +568,9 @@ class QueryChat(QueryChatBase):
561568
562569 """
563570
564- def server (self , * , enable_bookmarking : bool = False ) -> ServerValues :
571+ def server (
572+ self , * , enable_bookmarking : bool = False , id : Optional [str ] = None
573+ ) -> ServerValues :
565574 """
566575 Initialize Shiny server logic.
567576
@@ -574,6 +583,10 @@ def server(self, *, enable_bookmarking: bool = False) -> ServerValues:
574583 ----------
575584 enable_bookmarking
576585 Whether to enable bookmarking for the querychat module.
586+ id
587+ Optional module ID for the QueryChat instance. If not provided,
588+ will use the ID provided at initialization. This must match the ID
589+ used in the `.ui()` or `.sidebar()` methods.
577590
578591 Examples
579592 --------
@@ -629,7 +642,7 @@ def title():
629642 )
630643
631644 return mod_server (
632- self .id ,
645+ id or self .id ,
633646 data_source = self ._data_source ,
634647 greeting = self .greeting ,
635648 client = self .client ,
0 commit comments