Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg-py/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* The current SQL query and title can now be programmatically set through the `.sql()` and `.title()` methods of `QueryChat()`. (#98, #101)

* New `querychat.data` module provides sample datasets (`titanic()` and `tips()`) to make it easier to get started without external dependencies. (#118)

* Added a `.generate_greeting()` method to help you create a greeting message for your querychat bot. (#87)

* Added `querychat_reset_dashboard()` tool for easily resetting the dashboard filters when asked by the user. (#81)
Expand Down
2 changes: 2 additions & 0 deletions pkg-py/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* The current SQL query and title can now be programmatically set through the `.sql()` and `.title()` methods of `QueryChat()`. (#98, #101)

* New `querychat.data` module provides sample datasets (`titanic()` and `tips()`) to make it easier to get started without external dependencies. (#118)

* Added a `.generate_greeting()` method to help you create a greeting message for your querychat bot. (#87)

* Added `querychat_reset_dashboard()` tool for easily resetting the dashboard filters when asked by the user. (#81)
Expand Down
21 changes: 8 additions & 13 deletions pkg-py/docs/build.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,13 @@ Thanks to Shiny's support for [Jupyter Widgets](https://shiny.posit.co/py/docs/j
```python
import plotly.express as px

from seaborn import load_dataset
from shiny.express import render, ui
from shinywidgets import render_plotly

from querychat.express import QueryChat
from querychat.data import titanic

titanic = load_dataset("titanic")
qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")
qc.sidebar()

with ui.layout_columns():
Expand Down Expand Up @@ -223,12 +222,11 @@ A more useful, but slightly more involved example like the one below might incor
from shiny.express import render, ui
from shinywidgets import render_plotly
from querychat.express import QueryChat
from seaborn import load_dataset
from querychat.data import titanic
from faicons import icon_svg
import plotly.express as px

titanic = load_dataset("titanic")
qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")
qc.sidebar()

with ui.layout_column_wrap(fill=False):
Expand Down Expand Up @@ -356,11 +354,11 @@ You can use multiple QueryChat instances in a single app to explore different da
from seaborn import load_dataset
from shiny.express import render, ui
from querychat.express import QueryChat
from querychat.data import titanic

titanic = load_dataset("titanic")
penguins = load_dataset("penguins")

qc_titanic = QueryChat(titanic, "titanic")
qc_titanic = QueryChat(titanic(), "titanic")
qc_penguins = QueryChat(penguins, "penguins")

with ui.sidebar():
Expand Down Expand Up @@ -396,15 +394,12 @@ Here's a complete example bringing together multiple concepts - a Titanic surviv
```python
from shiny.express import render, ui
from querychat.express import QueryChat
from seaborn import load_dataset
from querychat.data import titanic
import plotly.express as px

# Load data
titanic = load_dataset("titanic")

# Create QueryChat
qc = QueryChat(
titanic,
titanic(),
"titanic",
data_description="Titanic passenger data with survival outcomes",
)
Expand Down
6 changes: 2 additions & 4 deletions pkg-py/docs/context.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ For full visibility into the full system prompt that Querychat generates for the

```python
from querychat import QueryChat
from seaborn import load_dataset
from querychat.data import titanic

titanic = load_dataset("titanic")

qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")
print(qc.system_prompt)
```

Expand Down
6 changes: 2 additions & 4 deletions pkg-py/docs/data-sources.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,10 @@ Or, if you have a pandas DataFrame, you can create the DuckDB database like so:
```{.python filename="create-duckdb-from-pandas.py"}
import duckdb
import pandas as pd

from seaborn import load_dataset
titanic = load_dataset("titanic")
from querychat.data import titanic

conn = duckdb.connect("my_database.duckdb")
conn.register('titanic_df', titanic)
conn.register('titanic_df', titanic())
conn.execute("""
CREATE TABLE titanic AS
SELECT * FROM titanic_df
Expand Down
5 changes: 2 additions & 3 deletions pkg-py/docs/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ The quickest way to start chatting is to call the `.app()` method, which returns


```{.python filename="titanic-app.py"}
from seaborn import load_dataset
from querychat import QueryChat
from querychat.data import titanic

titanic = load_dataset("titanic")
qc = QueryChat(titanic, "titanic", client="openai/gpt-4.1")
qc = QueryChat(titanic(), "titanic", client="openai/gpt-4.1")
app = qc.app()
```

Expand Down
5 changes: 2 additions & 3 deletions pkg-py/docs/models.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ To use a particular model, pass a `"{provider}/{model}"` string to the `client`

```python
from querychat import QueryChat
from seaborn import load_dataset
titanic = load_dataset("titanic")
from querychat.data import titanic

qc = QueryChat(
titanic,
titanic(),
"titanic",
client="anthropic/claude-sonnet-4-5"
)
Expand Down
10 changes: 4 additions & 6 deletions pkg-py/docs/tools.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ Here's a basic example of this tool in action with the `.app()` method. Notice h

```{.python filename="titanic-app.py"}
from querychat import QueryChat
from seaborn import load_dataset
from querychat.data import titanic

titanic = load_dataset("titanic")
qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")
app = qc.app()
```

Expand All @@ -46,10 +45,9 @@ Here's an example of it in action:

```{.python filename="titanic-app.py"}
from querychat import QueryChat
from seaborn import load_dataset
from querychat.data import titanic

titanic = load_dataset("titanic")
qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")
app = qc.app()
```

Expand Down
5 changes: 2 additions & 3 deletions pkg-py/examples/01-hello-app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from seaborn import load_dataset
from querychat import QueryChat
from querychat.data import titanic

titanic = load_dataset("titanic")
qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")
app = qc.app()
6 changes: 2 additions & 4 deletions pkg-py/examples/02-prompt-app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

from pathlib import Path
from seaborn import load_dataset
from querychat import QueryChat

titanic = load_dataset("titanic")
from querychat.data import titanic

greeting = Path(__file__).parent / "greeting.md"
data_desc = Path(__file__).parent / "data_description.md"

qc = QueryChat(
titanic,
titanic(),
"titanic",
greeting=greeting,
data_description=data_desc,
Expand Down
6 changes: 2 additions & 4 deletions pkg-py/examples/03-sidebar-core-app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from seaborn import load_dataset
from shiny import App, render, ui
from querychat import QueryChat

titanic = load_dataset("titanic")
from querychat.data import titanic

# 1. Provide data source to QueryChat
qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")

app_ui = ui.page_sidebar(
# 2. Create sidebar chat control
Expand Down
6 changes: 2 additions & 4 deletions pkg-py/examples/03-sidebar-express-app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from seaborn import load_dataset
from shiny.express import render, ui
from querychat.express import QueryChat

titanic = load_dataset("titanic")
from querychat.data import titanic

# 1. Provide data source to QueryChat
qc = QueryChat(titanic, "titanic")
qc = QueryChat(titanic(), "titanic")

# 2. Add sidebar chat control
qc.sidebar()
Expand Down
68 changes: 68 additions & 0 deletions pkg-py/src/querychat/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Sample datasets for getting started with querychat.

This module provides easy access to sample datasets that can be used with QueryChat
to quickly get started without needing to install additional dependencies.
"""

from __future__ import annotations

from importlib.resources import files

import pandas as pd


def titanic() -> pd.DataFrame:
"""
Load the Titanic dataset.

This dataset contains information about passengers on the Titanic, including
whether they survived, their class, age, sex, and other demographic information.

Returns
-------
pandas.DataFrame
A DataFrame with 891 rows and 15 columns containing Titanic passenger data.

Examples
--------
>>> from querychat.data import titanic
>>> from querychat import QueryChat
>>> df = titanic()
>>> qc = QueryChat(df, "titanic")
>>> app = qc.app()

"""
# Get the path to the gzipped CSV file using importlib.resources
data_file = files("querychat.data") / "titanic.csv.gz"
return pd.read_csv(str(data_file), compression="gzip")


def tips() -> pd.DataFrame:
"""
Load the tips dataset.

This dataset contains information about restaurant tips, including the total
bill, tip amount, and information about the party (sex, smoker status, day,
time, and party size).

Returns
-------
pandas.DataFrame
A DataFrame with 244 rows and 7 columns containing restaurant tip data.

Examples
--------
>>> from querychat.data import tips
>>> from querychat import QueryChat
>>> df = tips()
>>> qc = QueryChat(df, "tips")
>>> app = qc.app()

"""
# Get the path to the gzipped CSV file using importlib.resources
data_file = files("querychat.data") / "tips.csv.gz"
return pd.read_csv(str(data_file), compression="gzip")


__all__ = ["tips", "titanic"]
Binary file added pkg-py/src/querychat/data/tips.csv.gz
Binary file not shown.
Binary file added pkg-py/src/querychat/data/titanic.csv.gz
Binary file not shown.
Loading