querychat 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {querychat-0.2.0 → querychat-0.2.1}/PKG-INFO +1 -1
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/src/querychat/querychat.py +12 -13
- {querychat-0.2.0 → querychat-0.2.1}/pyproject.toml +1 -1
- {querychat-0.2.0 → querychat-0.2.1}/.gitignore +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/LICENSE.md +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/LICENSE +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/README.md +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/src/querychat/__init__.py +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/src/querychat/_utils.py +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/src/querychat/datasource.py +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/src/querychat/prompt/prompt.md +0 -0
- {querychat-0.2.0 → querychat-0.2.1}/pkg-py/src/querychat/static/css/styles.css +0 -0
|
@@ -18,7 +18,7 @@ from typing import (
|
|
|
18
18
|
|
|
19
19
|
import chatlas
|
|
20
20
|
import chevron
|
|
21
|
-
import narwhals as nw
|
|
21
|
+
import narwhals.stable.v1 as nw
|
|
22
22
|
import sqlalchemy
|
|
23
23
|
from shiny import Inputs, Outputs, Session, module, reactive, ui
|
|
24
24
|
|
|
@@ -26,7 +26,7 @@ from ._utils import temp_env_vars
|
|
|
26
26
|
|
|
27
27
|
if TYPE_CHECKING:
|
|
28
28
|
import pandas as pd
|
|
29
|
-
from narwhals.typing import IntoFrame
|
|
29
|
+
from narwhals.stable.v1.typing import IntoFrame
|
|
30
30
|
|
|
31
31
|
from .datasource import DataFrameSource, DataSource, SQLAlchemySource
|
|
32
32
|
|
|
@@ -224,16 +224,15 @@ def df_to_html(df: IntoFrame, maxrows: int = 5) -> str:
|
|
|
224
224
|
HTML string representation of the table
|
|
225
225
|
|
|
226
226
|
"""
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if isinstance(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
elif isinstance(df, nw.DataFrame):
|
|
233
|
-
ndf_eager = df
|
|
234
|
-
df_short = df.head(maxrows)
|
|
227
|
+
ndf = nw.from_native(df)
|
|
228
|
+
|
|
229
|
+
if isinstance(ndf, (nw.LazyFrame, nw.DataFrame)):
|
|
230
|
+
df_short = ndf.lazy().head(maxrows).collect()
|
|
231
|
+
nrow_full = ndf.lazy().select(nw.len()).collect().item()
|
|
235
232
|
else:
|
|
236
|
-
raise TypeError(
|
|
233
|
+
raise TypeError(
|
|
234
|
+
"Must be able to convert `df` into a Narwhals DataFrame or LazyFrame",
|
|
235
|
+
)
|
|
237
236
|
|
|
238
237
|
# Generate HTML table
|
|
239
238
|
table_html = df_short.to_pandas().to_html(
|
|
@@ -242,9 +241,9 @@ def df_to_html(df: IntoFrame, maxrows: int = 5) -> str:
|
|
|
242
241
|
)
|
|
243
242
|
|
|
244
243
|
# Add note about truncated rows if needed
|
|
245
|
-
if len(df_short) !=
|
|
244
|
+
if len(df_short) != nrow_full:
|
|
246
245
|
rows_notice = (
|
|
247
|
-
f"\n\n(Showing only the first {maxrows} rows out of {
|
|
246
|
+
f"\n\n(Showing only the first {maxrows} rows out of {nrow_full}.)\n"
|
|
248
247
|
)
|
|
249
248
|
else:
|
|
250
249
|
rows_notice = ""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|