-
Notifications
You must be signed in to change notification settings - Fork 24
feat(pkg-py): Add new QueryChat() API; hard deprecate old API
#101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
375b7d0
feat(pkg-py): First pass at new QueryChat() API
cpsievert b83320c
Update changelog
cpsievert 4291e4b
Fix format check
cpsievert 6d7c59e
Officially deprecate old API
cpsievert eaa8eb6
Fix import lint
cpsievert 07a8046
Consistent wording
cpsievert f26d4f8
Fix TypeError message
cpsievert a32401d
Address feedback
cpsievert f3c9bd8
Update changelog
cpsievert aab8b0a
Fix kwargs passed twice issue
cpsievert 732d699
Hard deprecate old API; update to latest chatlas
cpsievert 4cfa81e
3.9 typing support
cpsievert 3041a43
Simplify state
cpsievert 62a822f
Update changelog
cpsievert 5e3978d
fix name shadowing
cpsievert f7ce7ed
Address feedback
cpsievert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| from querychat._greeting import greeting | ||
| from querychat.querychat import ( | ||
| init, | ||
| sidebar, | ||
| system_prompt, | ||
| ) | ||
| from querychat.querychat import ( | ||
| mod_server as server, | ||
| ) | ||
| from querychat.querychat import ( | ||
| mod_ui as ui, | ||
| ) | ||
| from ._deprecated import greeting, init, sidebar, system_prompt | ||
| from ._deprecated import mod_server as server | ||
| from ._deprecated import mod_ui as ui | ||
| from ._querychat import QueryChat | ||
|
|
||
| __all__ = ["greeting", "init", "server", "sidebar", "system_prompt", "ui"] | ||
| __all__ = ( | ||
| "QueryChat", | ||
| # TODO(lifecycle): Remove these deprecated functions when we reach v1.0 | ||
| "greeting", | ||
| "init", | ||
| "server", | ||
| "sidebar", | ||
| "system_prompt", | ||
| "ui", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING, Any, Optional, Union | ||
|
|
||
| from shiny import Inputs, Outputs, Session, module, ui | ||
|
|
||
| if TYPE_CHECKING: | ||
| from pathlib import Path | ||
|
|
||
| import chatlas | ||
| import sqlalchemy | ||
| from narwhals.stable.v1.typing import IntoFrame | ||
|
|
||
| from .datasource import DataSource | ||
|
|
||
|
|
||
| def init( | ||
| data_source: IntoFrame | sqlalchemy.Engine, | ||
| table_name: str, | ||
| *, | ||
| greeting: Optional[str | Path] = None, | ||
| data_description: Optional[str | Path] = None, | ||
| extra_instructions: Optional[str | Path] = None, | ||
| prompt_template: Optional[str | Path] = None, | ||
| system_prompt_override: Optional[str] = None, | ||
| client: Optional[Union[chatlas.Chat, str]] = None, | ||
| ): | ||
| """ | ||
| Initialize querychat with any compliant data source. | ||
|
|
||
| **Deprecated.** Use `QueryChat()` instead. | ||
| """ | ||
| raise RuntimeError("init() is deprecated. Use QueryChat() instead.") | ||
|
|
||
|
|
||
| @module.ui | ||
| def mod_ui(**kwargs) -> ui.TagList: | ||
| """ | ||
| Create the UI for the querychat component. | ||
|
|
||
| **Deprecated.** Use `QueryChat.ui()` instead. | ||
| """ | ||
| raise RuntimeError("mod_ui() is deprecated. Use QueryChat.ui() instead.") | ||
|
|
||
|
|
||
| @module.server | ||
| def mod_server( | ||
| input: Inputs, | ||
| output: Outputs, | ||
| session: Session, | ||
| querychat_config: Any, | ||
| ): | ||
| """ | ||
| Initialize the querychat server. | ||
|
|
||
| **Deprecated.** Use `QueryChat.server()` instead. | ||
| """ | ||
| raise RuntimeError("mod_server() is deprecated. Use QueryChat.server() instead.") | ||
|
|
||
|
|
||
| def sidebar( | ||
| id: str, | ||
| width: int = 400, | ||
| height: str = "100%", | ||
| **kwargs, | ||
| ) -> ui.Sidebar: | ||
| """ | ||
| Create a sidebar containing the querychat UI. | ||
|
|
||
| **Deprecated.** Use `QueryChat.sidebar()` instead. | ||
| """ | ||
| raise RuntimeError("sidebar() is deprecated. Use QueryChat.sidebar() instead.") | ||
|
|
||
|
|
||
| def system_prompt( | ||
| data_source: DataSource, | ||
| *, | ||
| data_description: Optional[str | Path] = None, | ||
| extra_instructions: Optional[str | Path] = None, | ||
| categorical_threshold: int = 10, | ||
| prompt_template: Optional[str | Path] = None, | ||
| ) -> str: | ||
| """ | ||
| Create a system prompt for the chat model based on a data source's schema | ||
| and optional additional context and instructions. | ||
|
|
||
| **Deprecated.** Use `QueryChat.set_system_prompt()` instead. | ||
| """ | ||
| raise RuntimeError( | ||
| "system_prompt() is deprecated. Use QueryChat.set_system_prompt() instead." | ||
| ) | ||
|
|
||
|
|
||
| def greeting( | ||
| querychat_config, | ||
| *, | ||
| generate: bool = True, | ||
| stream: bool = False, | ||
| **kwargs, | ||
| ) -> str | None: | ||
| """ | ||
| Generate or retrieve a greeting message. | ||
|
|
||
| **Deprecated.** Use `QueryChat.generate_greeting()` instead. | ||
| """ | ||
| raise RuntimeError( | ||
| "greeting() is deprecated. Use QueryChat.generate_greeting() instead." | ||
| ) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.