Skip to content

Commit a32401d

Browse files
committed
Address feedback
1 parent f26d4f8 commit a32401d

File tree

9 files changed

+972
-738
lines changed

9 files changed

+972
-738
lines changed

pkg-py/src/querychat/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
from querychat.querychat import QueryChat
2-
1+
from . import express
32
from ._deprecated import greeting, init, sidebar, system_prompt
43
from ._deprecated import mod_server as server
54
from ._deprecated import mod_ui as ui
5+
from ._querychat import QueryChat
66

77
__all__ = (
88
"QueryChat",
9+
"express",
10+
# Old API (deprecated)
911
"greeting",
1012
"init",
1113
"server",

pkg-py/src/querychat/_deprecated.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import warnings
44
from copy import deepcopy
5+
from dataclasses import dataclass
56
from typing import TYPE_CHECKING, Optional, Union
67

78
from 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

1717
if TYPE_CHECKING:
@@ -24,6 +24,25 @@
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+
2746
def 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

Comments
 (0)