Skip to content

Commit a13172d

Browse files
committed
chore: take renaming suggestions
1 parent ade1a77 commit a13172d

File tree

15 files changed

+47
-47
lines changed

15 files changed

+47
-47
lines changed

pkg-py/src/querychat/_querychat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def __init__(
137137
)
138138

139139
# Fork and empty chat now so the per-session forks are fast
140-
client = normalize_client(client)
140+
client = as_querychat_client(client)
141141
self._client = copy.deepcopy(client)
142142
self._client.set_turns([])
143143
self._client.system_prompt = prompt
@@ -636,7 +636,7 @@ def normalize_data_source(
636636
return DataFrameSource(data_source, table_name)
637637

638638

639-
def normalize_client(client: str | chatlas.Chat | None) -> chatlas.Chat:
639+
def as_querychat_client(client: str | chatlas.Chat | None) -> chatlas.Chat:
640640
if client is None:
641641
client = os.getenv("QUERYCHAT_CLIENT", None)
642642

pkg-r/NAMESPACE

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

33
S3method(cleanup_source,dbi_source)
4-
S3method(create_data_source,DBIConnection)
5-
S3method(create_data_source,data.frame)
4+
S3method(as_querychat_data_source,DBIConnection)
5+
S3method(as_querychat_data_source,data.frame)
66
S3method(create_system_prompt,querychat_data_source)
77
S3method(execute_query,dbi_source)
88
S3method(get_db_type,data_frame_source)
@@ -12,7 +12,7 @@ S3method(get_schema,dbi_source)
1212
S3method(test_query,dbi_source)
1313
export(QueryChat)
1414
export(cleanup_source)
15-
export(create_data_source)
15+
export(as_querychat_data_source)
1616
export(create_system_prompt)
1717
export(execute_query)
1818
export(get_db_type)

pkg-r/NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# querychat (development version)
22

33
* 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 `create_data_source()`, and remains exported for a developer extension point, but users no longer have to explicitly create a data source. (#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)
55

66
* Added `prompt_template` support for `querychat_system_prompt()`. (Thank you, @oacar! #37, #45)
77

pkg-r/R/QueryChat.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ QueryChat <- R6::R6Class(
202202
)
203203

204204
# Fork and empty chat now so the per-session forks are fast
205-
client <- normalize_client(client)
205+
client <- as_querychat_client(client)
206206
private$.client <- client$clone()
207207
private$.client$set_turns(list())
208208
private$.client$set_system_prompt(prompt)
@@ -652,6 +652,6 @@ normalize_data_source <- function(data_source, table_name) {
652652
if (is_data_source(data_source)) {
653653
return(data_source)
654654
} else {
655-
create_data_source(data_source, table_name)
655+
as_querychat_data_source(data_source, table_name)
656656
}
657657
}

pkg-r/R/data_source.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#' @return A querychat_data_source object
1212
#' @keywords internal
1313
#' @export
14-
create_data_source <- function(x, table_name = NULL, ...) {
15-
UseMethod("create_data_source")
14+
as_querychat_data_source <- function(x, table_name = NULL, ...) {
15+
UseMethod("as_querychat_data_source")
1616
}
1717

1818
#' @export
19-
create_data_source.data.frame <- function(x, table_name = NULL, ...) {
19+
as_querychat_data_source.data.frame <- function(x, table_name = NULL, ...) {
2020
if (is.null(table_name)) {
2121
# Infer table name from dataframe name, if not already added
2222
table_name <- deparse(substitute(x))
@@ -47,7 +47,7 @@ create_data_source.data.frame <- function(x, table_name = NULL, ...) {
4747
}
4848

4949
#' @export
50-
create_data_source.DBIConnection <- function(x, table_name, ...) {
50+
as_querychat_data_source.DBIConnection <- function(x, table_name, ...) {
5151
# Handle different types of table_name inputs
5252
if (inherits(table_name, "Id")) {
5353
# DBI::Id object - keep as is

pkg-r/R/querychat-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#'
4242
#' @section Main Components:
4343
#' - [QueryChat]: The main R6 class for creating chat interfaces
44-
#' - [create_data_source()]: (Advanced) Create custom data source objects
44+
#' - [as_querychat_data_source()]: (Advanced) Create custom data source objects
4545
#'
4646
#' @section Examples:
4747
#' See the package examples directory for complete working apps:

pkg-r/R/utils-ellmer.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interpolate_package <- function(path, ..., .envir = parent.frame()) {
1515
}
1616

1717

18-
normalize_client <- function(client = NULL) {
18+
as_querychat_client <- function(client = NULL) {
1919
if (is.null(client)) {
2020
client <- querychat_client_option()
2121
}

pkg-r/man/create_data_source.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg-r/man/querychat-package.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg-r/tests/testthat/test-data-source.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ library(DBI)
33
library(RSQLite)
44
library(querychat)
55

6-
test_that("create_data_source.data.frame creates proper S3 object", {
6+
test_that("as_querychat_data_source.data.frame creates proper S3 object", {
77
# Create a simple data frame
88
test_df <- data.frame(
99
id = 1:5,
@@ -13,7 +13,7 @@ test_that("create_data_source.data.frame creates proper S3 object", {
1313
)
1414

1515
# Test with explicit table name
16-
source <- create_data_source(test_df, table_name = "test_table")
16+
source <- as_querychat_data_source(test_df, table_name = "test_table")
1717
withr::defer(cleanup_source(source))
1818

1919
expect_s3_class(source, "data_frame_source")
@@ -22,7 +22,7 @@ test_that("create_data_source.data.frame creates proper S3 object", {
2222
expect_true(inherits(source$conn, "DBIConnection"))
2323
})
2424

25-
test_that("create_data_source.DBIConnection creates proper S3 object", {
25+
test_that("as_querychat_data_source.DBIConnection creates proper S3 object", {
2626
# Create temporary SQLite database
2727
temp_db <- withr::local_tempfile(fileext = ".db")
2828
conn <- dbConnect(RSQLite::SQLite(), temp_db)
@@ -39,7 +39,7 @@ test_that("create_data_source.DBIConnection creates proper S3 object", {
3939
dbWriteTable(conn, "users", test_data, overwrite = TRUE)
4040

4141
# Test DBI source creation
42-
db_source <- create_data_source(conn, "users")
42+
db_source <- as_querychat_data_source(conn, "users")
4343
expect_s3_class(db_source, "dbi_source")
4444
expect_s3_class(db_source, "querychat_data_source")
4545
expect_equal(db_source$table_name, "users")
@@ -54,7 +54,7 @@ test_that("get_schema methods return proper schema", {
5454
stringsAsFactors = FALSE
5555
)
5656

57-
df_source <- create_data_source(test_df, table_name = "test_table")
57+
df_source <- as_querychat_data_source(test_df, table_name = "test_table")
5858
withr::defer(cleanup_source(df_source))
5959

6060
schema <- get_schema(df_source)
@@ -75,7 +75,7 @@ test_that("get_schema methods return proper schema", {
7575

7676
dbWriteTable(conn, "test_table", test_df, overwrite = TRUE)
7777

78-
dbi_source <- create_data_source(conn, "test_table")
78+
dbi_source <- as_querychat_data_source(conn, "test_table")
7979
schema <- get_schema(dbi_source)
8080
expect_type(schema, "character")
8181
expect_match(schema, "Table: `test_table`")
@@ -94,7 +94,7 @@ test_that("execute_query works for both source types", {
9494
stringsAsFactors = FALSE
9595
)
9696

97-
df_source <- create_data_source(test_df, table_name = "test_table")
97+
df_source <- as_querychat_data_source(test_df, table_name = "test_table")
9898
withr::defer(cleanup_source(df_source))
9999
result <- execute_query(
100100
df_source,
@@ -109,7 +109,7 @@ test_that("execute_query works for both source types", {
109109
withr::defer(dbDisconnect(conn))
110110
dbWriteTable(conn, "test_table", test_df, overwrite = TRUE)
111111

112-
dbi_source <- create_data_source(conn, "test_table")
112+
dbi_source <- as_querychat_data_source(conn, "test_table")
113113
result <- execute_query(
114114
dbi_source,
115115
"SELECT * FROM test_table WHERE value > 25"
@@ -126,7 +126,7 @@ test_that("execute_query works with empty/null queries", {
126126
stringsAsFactors = FALSE
127127
)
128128

129-
df_source <- create_data_source(test_df, table_name = "test_table")
129+
df_source <- as_querychat_data_source(test_df, table_name = "test_table")
130130
withr::defer(cleanup_source(df_source))
131131

132132
# Test with NULL query
@@ -148,7 +148,7 @@ test_that("execute_query works with empty/null queries", {
148148

149149
dbWriteTable(conn, "test_table", test_df, overwrite = TRUE)
150150

151-
dbi_source <- create_data_source(conn, "test_table")
151+
dbi_source <- as_querychat_data_source(conn, "test_table")
152152

153153
# Test with NULL query
154154
result_null <- execute_query(dbi_source, NULL)
@@ -173,7 +173,7 @@ test_that("get_schema correctly reports min/max values for numeric columns", {
173173
stringsAsFactors = FALSE
174174
)
175175

176-
df_source <- create_data_source(test_df, table_name = "test_metrics")
176+
df_source <- as_querychat_data_source(test_df, table_name = "test_metrics")
177177
withr::defer(cleanup_source(df_source))
178178
schema <- get_schema(df_source)
179179

@@ -191,7 +191,7 @@ test_that("create_system_prompt generates appropriate system prompt", {
191191
stringsAsFactors = FALSE
192192
)
193193

194-
df_source <- create_data_source(test_df, table_name = "test_table")
194+
df_source <- as_querychat_data_source(test_df, table_name = "test_table")
195195
withr::defer(cleanup_source(df_source))
196196

197197
prompt <- create_system_prompt(
@@ -220,7 +220,7 @@ test_that("QueryChat$new() automatically handles data.frame inputs", {
220220
expect_s3_class(qc$data_source, "data_frame_source")
221221

222222
# Should work with proper data source too
223-
df_source <- create_data_source(test_df, table_name = "test_table")
223+
df_source <- as_querychat_data_source(test_df, table_name = "test_table")
224224
withr::defer(cleanup_source(df_source))
225225

226226
qc2 <- QueryChat$new(
@@ -240,7 +240,7 @@ test_that("QueryChat$new() works with both source types", {
240240
)
241241

242242
# Create data source and test with QueryChat$new()
243-
df_source <- create_data_source(test_df, table_name = "test_source")
243+
df_source <- as_querychat_data_source(test_df, table_name = "test_source")
244244
withr::defer(cleanup_source(df_source))
245245

246246
qc <- QueryChat$new(
@@ -259,7 +259,7 @@ test_that("QueryChat$new() works with both source types", {
259259

260260
dbWriteTable(conn, "test_table", test_df, overwrite = TRUE)
261261

262-
dbi_source <- create_data_source(conn, "test_table")
262+
dbi_source <- as_querychat_data_source(conn, "test_table")
263263
qc2 <- QueryChat$new(
264264
data_source = dbi_source,
265265
table_name = "test_table",

0 commit comments

Comments
 (0)