22
33import warnings
44from copy import deepcopy
5+ from dataclasses import dataclass
56from typing import TYPE_CHECKING , Optional , Union
67
78from shiny import Inputs , Outputs , Session , module , ui
89
9- from .querychat import (
10- QueryChatConfig ,
11- _init_impl ,
12- _server_impl ,
13- _system_prompt_impl ,
14- _ui_impl ,
10+ from ._querychat_impl import (
11+ init_impl ,
12+ server_impl ,
13+ system_prompt_impl ,
14+ ui_impl ,
1515)
1616
1717if TYPE_CHECKING :
2424 from .datasource import DataSource
2525
2626
27+ @dataclass
28+ class QueryChatConfig :
29+ """
30+ Configuration class for querychat.
31+
32+ Warning:
33+ -------
34+ This class only exists as the return value of `init()`, which is deprecated,
35+ and so will likely be removed in a future release. New code should use
36+ `QueryChat()`.
37+
38+ """
39+
40+ data_source : DataSource
41+ system_prompt : str
42+ greeting : Optional [str ]
43+ client : chatlas .Chat
44+
45+
2746def init (
2847 data_source : IntoFrame | sqlalchemy .Engine ,
2948 table_name : str ,
@@ -52,7 +71,7 @@ def init(
5271 "init() is deprecated and will be removed in a future release. "
5372 "Use QueryChat() instead."
5473 )
55- return _init_impl (
74+ res = init_impl (
5675 data_source ,
5776 table_name ,
5877 greeting = greeting ,
@@ -62,6 +81,7 @@ def init(
6281 system_prompt_override = system_prompt_override ,
6382 client = client ,
6483 )
84+ return QueryChatConfig (** res )
6585
6686
6787@module .ui
@@ -78,7 +98,7 @@ def mod_ui(**kwargs) -> ui.TagList:
7898 "ui() is deprecated and will be removed in a future release. "
7999 "Use QueryChat.ui() instead."
80100 )
81- return _ui_impl (** kwargs )
101+ return ui_impl (** kwargs )
82102
83103
84104@module .server
@@ -102,11 +122,14 @@ def mod_server(
102122 FutureWarning ,
103123 stacklevel = 2 ,
104124 )
105- return _server_impl (
125+ return server_impl (
106126 input ,
107127 output ,
108128 session ,
109- querychat_config ,
129+ data_source = querychat_config .data_source ,
130+ system_prompt = querychat_config .system_prompt ,
131+ greeting = querychat_config .greeting ,
132+ client = querychat_config .client ,
110133 )
111134
112135
@@ -165,7 +188,7 @@ def system_prompt(
165188 FutureWarning ,
166189 stacklevel = 2 ,
167190 )
168- return _system_prompt_impl (
191+ return system_prompt_impl (
169192 data_source ,
170193 data_description = data_description ,
171194 extra_instructions = extra_instructions ,
0 commit comments