Skip to content

Commit 2a521cb

Browse files
cpsievertgadenbuie
andauthored
feat!(pkg-r): new QueryChat API (#109)
* feat(pkg-r): first pass at new QueryChat() API * `air format` (GitHub Actions) * `usethis::use_tidy_description()` (GitHub Actions) * Address feedback * Get check passing * Add some DT/card polish to () and examples * `air format` (GitHub Actions) * Apply suggestions from code review Co-authored-by: Garrick Aden-Buie <[email protected]> * chore: rename file * Apply suggestions from code review Co-authored-by: Garrick Aden-Buie <[email protected]> * chore: take renaming suggestions * `devtools::document()` (GitHub Actions) * fix: pass along ... correctly * fix: don't cleanup automatically when QueryChat gets initialized outside of active session * `devtools::document()` (GitHub Actions) * fix: mention shiny::runExample() * `air format` (GitHub Actions) * `devtools::document()` (GitHub Actions) * feat: Add querychat() and querychat_app() convenience functions * fix: cleanup default value * `devtools::document()` (GitHub Actions) * feat: Add app_obj() method * `devtools::document()` (GitHub Actions) * fix: enforce session-specific server values by accessing through (); handle fallout and address feedback * Address feedback --------- Co-authored-by: cpsievert <[email protected]> Co-authored-by: Garrick Aden-Buie <[email protected]>
1 parent 7c93d09 commit 2a521cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2292
-1094
lines changed

pkg-py/src/querychat/_querychat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(
6767
)
6868

6969
# Fork and empty chat now so the per-session forks are fast
70-
client = normalize_client(client)
70+
client = as_querychat_client(client)
7171
self._client = copy.deepcopy(client)
7272
self._client.set_turns([])
7373
self._client.system_prompt = prompt
@@ -665,7 +665,7 @@ def normalize_data_source(
665665
return DataFrameSource(data_source, table_name)
666666

667667

668-
def normalize_client(client: str | chatlas.Chat | None) -> chatlas.Chat:
668+
def as_querychat_client(client: str | chatlas.Chat | None) -> chatlas.Chat:
669669
if client is None:
670670
client = os.getenv("QUERYCHAT_CLIENT", None)
671671

pkg-r/DESCRIPTION

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: querychat
22
Title: Filter and Query Data Frames in 'shiny' Using an LLM Chat Interface
3-
Version: 0.0.1.9000
3+
Version: 0.1.0.9000
44
Authors@R: c(
55
person("Joe", "Cheng", , "[email protected]", role = c("aut", "cre")),
66
person("Posit Software, PBC", role = c("cph", "fnd"))
@@ -23,17 +23,16 @@ Imports:
2323
lifecycle,
2424
promises,
2525
purrr,
26+
R6,
2627
rlang,
2728
shiny,
2829
shinychat (>= 0.2.0.9000),
2930
utils,
30-
whisker,
31-
xtable
31+
whisker
3232
Suggests:
3333
bsicons,
3434
DT,
3535
palmerpenguins,
36-
R6,
3736
RSQLite,
3837
shinytest2,
3938
testthat (>= 3.0.0),

pkg-r/NAMESPACE

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(as_querychat_data_source,DBIConnection)
4+
S3method(as_querychat_data_source,data.frame)
35
S3method(cleanup_source,dbi_source)
46
S3method(create_system_prompt,querychat_data_source)
57
S3method(execute_query,dbi_source)
68
S3method(get_db_type,data_frame_source)
79
S3method(get_db_type,dbi_source)
810
S3method(get_db_type,default)
911
S3method(get_schema,dbi_source)
10-
S3method(querychat_data_source,DBIConnection)
11-
S3method(querychat_data_source,data.frame)
1212
S3method(test_query,dbi_source)
13+
export(QueryChat)
14+
export(as_querychat_data_source)
1315
export(cleanup_source)
1416
export(create_system_prompt)
1517
export(execute_query)
1618
export(get_db_type)
1719
export(get_schema)
20+
export(querychat)
1821
export(querychat_app)
1922
export(querychat_data_source)
2023
export(querychat_greeting)
@@ -23,4 +26,7 @@ export(querychat_server)
2326
export(querychat_sidebar)
2427
export(querychat_ui)
2528
export(test_query)
29+
importFrom(R6,R6Class)
30+
importFrom(bslib,sidebar)
2631
importFrom(lifecycle,deprecated)
32+
importFrom(rlang,"%||%")

pkg-r/NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# querychat (development version)
22

3+
* Nearly the entire functional API (i.e., `querychat_init()`, `querychat_sidebar()`, `querychat_server()`, etc) has been hard deprecated in favor of a simpler OOP-based API. Namely, the new `QueryChat$new()` class is now the main entry point (instead of `querychat_init()`) and has methods to replace old functions (e.g., `$sidebar()`, `$server()`, etc). (#109)
4+
* In addition, `querychat_data_source()` was renamed to `as_querychat_data_source()`, and remains exported for a developer extension point, but users no longer have to explicitly create a data source. (#109)
5+
36
* Added `prompt_template` support for `querychat_system_prompt()`. (Thank you, @oacar! #37, #45)
47

58
* `querychat_init()` now accepts a `client`, replacing the previous `create_chat_func` argument. (#60)

0 commit comments

Comments
 (0)