From b87b7c84fd215cf0ceb261f873c5dcb104d5ec3a Mon Sep 17 00:00:00 2001 From: Garrett Grolemund Date: Thu, 26 Sep 2024 13:37:59 -0500 Subject: [PATCH 1/6] Adds README with Connect Cloud button to airmass example --- examples/airmass/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 examples/airmass/README.md diff --git a/examples/airmass/README.md b/examples/airmass/README.md new file mode 100644 index 000000000..6b44947f7 --- /dev/null +++ b/examples/airmass/README.md @@ -0,0 +1,3 @@ +## Airmass app + +[![](https://docs.posit.co/connect-cloud/images/cc-deploy.svg)](https://connect.posit.cloud/publish?framework=shiny&sourceRepositoryURL=https%3A%2F%2Fgithub.com%2Fposit-dev%2Fpy-shiny&sourceRef=main&sourceRefType=branch&primaryFile=examples%2Fairmass%2Fapp.py&pythonVersion=3.11) From 9967da7b532e2d27f59d0843ff4b2ababe6abfbb Mon Sep 17 00:00:00 2001 From: Garrett Grolemund Date: Wed, 2 Oct 2024 09:56:50 -0500 Subject: [PATCH 2/6] Right aligns button, updates image link to the CDN. --- examples/airmass/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/airmass/README.md b/examples/airmass/README.md index 6b44947f7..135269eb0 100644 --- a/examples/airmass/README.md +++ b/examples/airmass/README.md @@ -1,3 +1,3 @@ ## Airmass app -[![](https://docs.posit.co/connect-cloud/images/cc-deploy.svg)](https://connect.posit.cloud/publish?framework=shiny&sourceRepositoryURL=https%3A%2F%2Fgithub.com%2Fposit-dev%2Fpy-shiny&sourceRef=main&sourceRefType=branch&primaryFile=examples%2Fairmass%2Fapp.py&pythonVersion=3.11) + From 5b4e4f6d3b97d4b7837896e11e4950d812e13c80 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Wed, 2 Oct 2024 16:20:14 -0400 Subject: [PATCH 3/6] Add untested requirements.txt and basic readme.md files in each `./examples` app dirs. --- examples/annotation-export/README.md | 3 ++ examples/annotation-export/requirements.txt | 2 ++ examples/brownian/README.md | 3 ++ examples/busy_indicators/README.md | 3 ++ examples/busy_indicators/requirements.txt | 3 ++ examples/chat/RAG/recipes/requirements.txt | 4 +++ examples/chat/README.md | 16 ++++++++++ examples/chat/hello-world/requirements.txt | 1 + examples/chat/playground/requirements.txt | 4 +++ examples/chat/ui/clear/requirements.txt | 2 ++ examples/chat/ui/dark/requirements.txt | 2 ++ examples/chat/ui/dynamic/requirements.txt | 2 ++ examples/chat/ui/sidebar/requirements.txt | 2 ++ examples/cpuinfo/README.md | 3 ++ examples/cpuinfo/requirements.txt | 5 ++++ examples/dataframe/README.md | 3 ++ examples/dataframe/requirements.txt | 4 +++ examples/duckdb/README.md | 3 ++ examples/duckdb/requirements.txt | 2 +- examples/event/README.md | 3 ++ examples/event/requirements.txt | 1 + examples/express/README.md | 33 +++++++++++++++++++++ examples/express/requirements.txt | 3 ++ examples/global_pyplot/README.md | 3 ++ examples/global_pyplot/requirements.txt | 2 ++ examples/headers/README.md | 3 ++ examples/headers/requirements.txt | 1 + examples/inputs-update/README.md | 3 ++ examples/inputs-update/requirements.txt | 1 + examples/load_balance/README.md | 3 ++ examples/load_balance/requirements.txt | 2 ++ examples/model-score/README.md | 3 ++ examples/model-score/requirements.txt | 1 + examples/moduleapp/README.md | 3 ++ examples/moduleapp/requirements.txt | 1 + examples/penguins/README.md | 3 ++ examples/penguins/requirements.txt | 4 +-- examples/req/README.md | 3 ++ examples/req/requirements.txt | 1 + examples/static_plots/README.md | 3 ++ examples/static_plots/requirements.txt | 6 ++++ examples/typed_inputs/README.md | 3 ++ examples/typed_inputs/requirements.txt | 1 + examples/ui-func/README.md | 3 ++ examples/ui-func/requirements.txt | 2 ++ 45 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 examples/annotation-export/README.md create mode 100644 examples/brownian/README.md create mode 100644 examples/busy_indicators/README.md create mode 100644 examples/busy_indicators/requirements.txt create mode 100644 examples/chat/RAG/recipes/requirements.txt create mode 100644 examples/chat/hello-world/requirements.txt create mode 100644 examples/chat/playground/requirements.txt create mode 100644 examples/chat/ui/clear/requirements.txt create mode 100644 examples/chat/ui/dark/requirements.txt create mode 100644 examples/chat/ui/dynamic/requirements.txt create mode 100644 examples/chat/ui/sidebar/requirements.txt create mode 100644 examples/cpuinfo/README.md create mode 100644 examples/cpuinfo/requirements.txt create mode 100644 examples/dataframe/README.md create mode 100644 examples/dataframe/requirements.txt create mode 100644 examples/duckdb/README.md create mode 100644 examples/event/README.md create mode 100644 examples/event/requirements.txt create mode 100644 examples/express/README.md create mode 100644 examples/express/requirements.txt create mode 100644 examples/global_pyplot/README.md create mode 100644 examples/global_pyplot/requirements.txt create mode 100644 examples/headers/README.md create mode 100644 examples/headers/requirements.txt create mode 100644 examples/inputs-update/README.md create mode 100644 examples/inputs-update/requirements.txt create mode 100644 examples/load_balance/README.md create mode 100644 examples/load_balance/requirements.txt create mode 100644 examples/model-score/README.md create mode 100644 examples/moduleapp/README.md create mode 100644 examples/moduleapp/requirements.txt create mode 100644 examples/penguins/README.md create mode 100644 examples/req/README.md create mode 100644 examples/req/requirements.txt create mode 100644 examples/static_plots/README.md create mode 100644 examples/static_plots/requirements.txt create mode 100644 examples/typed_inputs/README.md create mode 100644 examples/typed_inputs/requirements.txt create mode 100644 examples/ui-func/README.md create mode 100644 examples/ui-func/requirements.txt diff --git a/examples/annotation-export/README.md b/examples/annotation-export/README.md new file mode 100644 index 000000000..dc68b756b --- /dev/null +++ b/examples/annotation-export/README.md @@ -0,0 +1,3 @@ +## Plot annotation app + + diff --git a/examples/annotation-export/requirements.txt b/examples/annotation-export/requirements.txt index 4695c7070..6a921d305 100644 --- a/examples/annotation-export/requirements.txt +++ b/examples/annotation-export/requirements.txt @@ -1,2 +1,4 @@ seaborn pandas +shiny +matplotlib diff --git a/examples/brownian/README.md b/examples/brownian/README.md new file mode 100644 index 000000000..e3605b8cd --- /dev/null +++ b/examples/brownian/README.md @@ -0,0 +1,3 @@ +## Hand-driven data exploration app + + diff --git a/examples/busy_indicators/README.md b/examples/busy_indicators/README.md new file mode 100644 index 000000000..bfea496a6 --- /dev/null +++ b/examples/busy_indicators/README.md @@ -0,0 +1,3 @@ +## Busy indicators app + + diff --git a/examples/busy_indicators/requirements.txt b/examples/busy_indicators/requirements.txt new file mode 100644 index 000000000..8cc6a66a2 --- /dev/null +++ b/examples/busy_indicators/requirements.txt @@ -0,0 +1,3 @@ +numpy +seaborn +shiny diff --git a/examples/chat/RAG/recipes/requirements.txt b/examples/chat/RAG/recipes/requirements.txt new file mode 100644 index 000000000..54b14a013 --- /dev/null +++ b/examples/chat/RAG/recipes/requirements.txt @@ -0,0 +1,4 @@ +aiohttp +bs4 +openai +shiny diff --git a/examples/chat/README.md b/examples/chat/README.md index c5a366394..eb2b59363 100644 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -1,5 +1,21 @@ # Shiny `Chat` examples + This folder contains a collection of examples illustrating `shiny.ui.Chat` usage. Many of them require API keys from providers such as OpenAI, Anthropic, etc. In those cases, the example should have commentary explaining how to obtain keys as well as how to provide them to the app. To get started with an app that doesn't require an API key, see the `hello-world` example. This example has both a Shiny Core and Express app to illustrate how it's used in either mode. + + +----------------------- + +## Apps + +* [hello-world](hello-world): A simple chat app that echoes back the user's input. +* [playground](playground): A playground for testing out different chat models: `openai`, `claude`, and `google`. +* RAG + * [recipes](RAG/recipes): A simple recipe extractor chatbot that extracts recipes from URLs using the OpenAI API. +* UI + * [clear](ui/clear): This example demonstrates how to clear the chat when the model changes. + * [dark](ui/dark): This example demonstrates Shiny Chat's dark mode capability. + * [dynamic](ui/dynamic): A basic example of dynamically re-rendering a Shiny Chat instance with different models. + * [sidebar](ui/sidebar): An example of placing a Shiny Chat instance in a sidebar (and having it fill the sidebar). diff --git a/examples/chat/hello-world/requirements.txt b/examples/chat/hello-world/requirements.txt new file mode 100644 index 000000000..3e78250b6 --- /dev/null +++ b/examples/chat/hello-world/requirements.txt @@ -0,0 +1 @@ +shiny diff --git a/examples/chat/playground/requirements.txt b/examples/chat/playground/requirements.txt new file mode 100644 index 000000000..29bb799b8 --- /dev/null +++ b/examples/chat/playground/requirements.txt @@ -0,0 +1,4 @@ +langchain_anthropic +langchain_google_vertexai +langchain_openai +shiny diff --git a/examples/chat/ui/clear/requirements.txt b/examples/chat/ui/clear/requirements.txt new file mode 100644 index 000000000..74bdc42cd --- /dev/null +++ b/examples/chat/ui/clear/requirements.txt @@ -0,0 +1,2 @@ +langchain_openai +shiny diff --git a/examples/chat/ui/dark/requirements.txt b/examples/chat/ui/dark/requirements.txt new file mode 100644 index 000000000..74bdc42cd --- /dev/null +++ b/examples/chat/ui/dark/requirements.txt @@ -0,0 +1,2 @@ +langchain_openai +shiny diff --git a/examples/chat/ui/dynamic/requirements.txt b/examples/chat/ui/dynamic/requirements.txt new file mode 100644 index 000000000..74bdc42cd --- /dev/null +++ b/examples/chat/ui/dynamic/requirements.txt @@ -0,0 +1,2 @@ +langchain_openai +shiny diff --git a/examples/chat/ui/sidebar/requirements.txt b/examples/chat/ui/sidebar/requirements.txt new file mode 100644 index 000000000..74bdc42cd --- /dev/null +++ b/examples/chat/ui/sidebar/requirements.txt @@ -0,0 +1,2 @@ +langchain_openai +shiny diff --git a/examples/cpuinfo/README.md b/examples/cpuinfo/README.md new file mode 100644 index 000000000..69defb255 --- /dev/null +++ b/examples/cpuinfo/README.md @@ -0,0 +1,3 @@ +## CPU usage app + + diff --git a/examples/cpuinfo/requirements.txt b/examples/cpuinfo/requirements.txt new file mode 100644 index 000000000..91b6de986 --- /dev/null +++ b/examples/cpuinfo/requirements.txt @@ -0,0 +1,5 @@ +matplotlib +numpy +pandas +psutil +shiny diff --git a/examples/dataframe/README.md b/examples/dataframe/README.md new file mode 100644 index 000000000..629d00a93 --- /dev/null +++ b/examples/dataframe/README.md @@ -0,0 +1,3 @@ +## Data frame viewer + + diff --git a/examples/dataframe/requirements.txt b/examples/dataframe/requirements.txt new file mode 100644 index 000000000..4702dcbc4 --- /dev/null +++ b/examples/dataframe/requirements.txt @@ -0,0 +1,4 @@ +pandas +seaborn +shiny +shinyswatch diff --git a/examples/duckdb/README.md b/examples/duckdb/README.md new file mode 100644 index 000000000..6a66eb541 --- /dev/null +++ b/examples/duckdb/README.md @@ -0,0 +1,3 @@ +## DuckDB query weather explorer + + diff --git a/examples/duckdb/requirements.txt b/examples/duckdb/requirements.txt index 71bb3d1d9..4eb669cd9 100644 --- a/examples/duckdb/requirements.txt +++ b/examples/duckdb/requirements.txt @@ -1,4 +1,4 @@ duckdb +pandas shiny shinyswatch -pandas diff --git a/examples/event/README.md b/examples/event/README.md new file mode 100644 index 000000000..679f6d62e --- /dev/null +++ b/examples/event/README.md @@ -0,0 +1,3 @@ +## Sync / Async events + + diff --git a/examples/event/requirements.txt b/examples/event/requirements.txt new file mode 100644 index 000000000..3e78250b6 --- /dev/null +++ b/examples/event/requirements.txt @@ -0,0 +1 @@ +shiny diff --git a/examples/express/README.md b/examples/express/README.md new file mode 100644 index 000000000..ab7a3151e --- /dev/null +++ b/examples/express/README.md @@ -0,0 +1,33 @@ +## `shiny.express` examples + +This folder contains a collection of examples illustrating `shiny.express` usage. + +### Apps + +* [`accordion_app.py`](accordion_app.py): + * Integrates `ui.accordion()` and `ui.accordion_panel()`. + +* [`basic_app.py`](basic_app.py): + * Basic app containing a `ui.input_slider()` and `ui.output_code()`. + +* [`column_wrap_app.py`](basic_app.py): + * Basic app containing a `ui.input_slider()` and `ui.output_code()`. + +* [`expressify_app.py`](expressify_app.py): + * Demonstrates how to use `@expressify` to convert regular functions into _express_ compatible functions. + +* [`hold_app.py`](hold_app.py): + * Demonstrates how to use `@hold` to prevent the app from updating. + +* [`nav_app.py`](nav_app.py): + * Demonstrates how to use different navsets along with `ui.nav_panel()`. + +* [`plot_app.py`](plot_app.py): + * Demonstrates how plot render methods are rendered in place. + +* [`render_express_app.py`](render_express_app.py): + * Demonstrates how to use `@render.express()` (similar to `@render.ui()`), but for _express_ functions. + +* [`shared_app.py`](shared_app.py): + * This app demonstrates how to use "global" variables that are shared across sessions. + * This is useful if you want to load data just once and use it in multiple apps, or if you want to share data or reactives among apps. diff --git a/examples/express/requirements.txt b/examples/express/requirements.txt new file mode 100644 index 000000000..b079970cd --- /dev/null +++ b/examples/express/requirements.txt @@ -0,0 +1,3 @@ +matplotlib +numpy +shiny diff --git a/examples/global_pyplot/README.md b/examples/global_pyplot/README.md new file mode 100644 index 000000000..39a635c47 --- /dev/null +++ b/examples/global_pyplot/README.md @@ -0,0 +1,3 @@ +## Plotting with `matplotlib.pyplot` + + diff --git a/examples/global_pyplot/requirements.txt b/examples/global_pyplot/requirements.txt new file mode 100644 index 000000000..400f73f5f --- /dev/null +++ b/examples/global_pyplot/requirements.txt @@ -0,0 +1,2 @@ +matplotlib +shiny diff --git a/examples/headers/README.md b/examples/headers/README.md new file mode 100644 index 000000000..2dddf3be0 --- /dev/null +++ b/examples/headers/README.md @@ -0,0 +1,3 @@ +## HTTP request headers app + + diff --git a/examples/headers/requirements.txt b/examples/headers/requirements.txt new file mode 100644 index 000000000..3e78250b6 --- /dev/null +++ b/examples/headers/requirements.txt @@ -0,0 +1 @@ +shiny diff --git a/examples/inputs-update/README.md b/examples/inputs-update/README.md new file mode 100644 index 000000000..ac9c8c9d1 --- /dev/null +++ b/examples/inputs-update/README.md @@ -0,0 +1,3 @@ +## Updating shiny inputs + + diff --git a/examples/inputs-update/requirements.txt b/examples/inputs-update/requirements.txt new file mode 100644 index 000000000..3e78250b6 --- /dev/null +++ b/examples/inputs-update/requirements.txt @@ -0,0 +1 @@ +shiny diff --git a/examples/load_balance/README.md b/examples/load_balance/README.md new file mode 100644 index 000000000..495d3da59 --- /dev/null +++ b/examples/load_balance/README.md @@ -0,0 +1,3 @@ +## Sticky load balance test app + + diff --git a/examples/load_balance/requirements.txt b/examples/load_balance/requirements.txt new file mode 100644 index 000000000..71022f994 --- /dev/null +++ b/examples/load_balance/requirements.txt @@ -0,0 +1,2 @@ +shiny +starlette diff --git a/examples/model-score/README.md b/examples/model-score/README.md new file mode 100644 index 000000000..45205eceb --- /dev/null +++ b/examples/model-score/README.md @@ -0,0 +1,3 @@ +## Model monitoring dashboard + + diff --git a/examples/model-score/requirements.txt b/examples/model-score/requirements.txt index 1a5617b60..a87615d6d 100644 --- a/examples/model-score/requirements.txt +++ b/examples/model-score/requirements.txt @@ -1,3 +1,4 @@ +numpy pandas plotly shiny diff --git a/examples/moduleapp/README.md b/examples/moduleapp/README.md new file mode 100644 index 000000000..45205eceb --- /dev/null +++ b/examples/moduleapp/README.md @@ -0,0 +1,3 @@ +## Model monitoring dashboard + + diff --git a/examples/moduleapp/requirements.txt b/examples/moduleapp/requirements.txt new file mode 100644 index 000000000..3e78250b6 --- /dev/null +++ b/examples/moduleapp/requirements.txt @@ -0,0 +1 @@ +shiny diff --git a/examples/penguins/README.md b/examples/penguins/README.md new file mode 100644 index 000000000..b16135304 --- /dev/null +++ b/examples/penguins/README.md @@ -0,0 +1,3 @@ +## Penguins dashboard + + diff --git a/examples/penguins/requirements.txt b/examples/penguins/requirements.txt index 14d67b478..35f60813f 100644 --- a/examples/penguins/requirements.txt +++ b/examples/penguins/requirements.txt @@ -1,4 +1,4 @@ -shiny -shinyswatch +matplotlib pandas seaborn +shiny diff --git a/examples/req/README.md b/examples/req/README.md new file mode 100644 index 000000000..7fb618939 --- /dev/null +++ b/examples/req/README.md @@ -0,0 +1,3 @@ +## Error handling example app + + diff --git a/examples/req/requirements.txt b/examples/req/requirements.txt new file mode 100644 index 000000000..3e78250b6 --- /dev/null +++ b/examples/req/requirements.txt @@ -0,0 +1 @@ +shiny diff --git a/examples/static_plots/README.md b/examples/static_plots/README.md new file mode 100644 index 000000000..94baf664a --- /dev/null +++ b/examples/static_plots/README.md @@ -0,0 +1,3 @@ +## Static Plots + + diff --git a/examples/static_plots/requirements.txt b/examples/static_plots/requirements.txt new file mode 100644 index 000000000..dcb817f56 --- /dev/null +++ b/examples/static_plots/requirements.txt @@ -0,0 +1,6 @@ +matplotlib +numpy +pandas +seaborn +plotnine +shiny diff --git a/examples/typed_inputs/README.md b/examples/typed_inputs/README.md new file mode 100644 index 000000000..91d2d6704 --- /dev/null +++ b/examples/typed_inputs/README.md @@ -0,0 +1,3 @@ +## Typed inputs + + diff --git a/examples/typed_inputs/requirements.txt b/examples/typed_inputs/requirements.txt new file mode 100644 index 000000000..3e78250b6 --- /dev/null +++ b/examples/typed_inputs/requirements.txt @@ -0,0 +1 @@ +shiny diff --git a/examples/ui-func/README.md b/examples/ui-func/README.md new file mode 100644 index 000000000..0b4fd38cf --- /dev/null +++ b/examples/ui-func/README.md @@ -0,0 +1,3 @@ +## UI as a function + + diff --git a/examples/ui-func/requirements.txt b/examples/ui-func/requirements.txt new file mode 100644 index 000000000..71022f994 --- /dev/null +++ b/examples/ui-func/requirements.txt @@ -0,0 +1,2 @@ +shiny +starlette From 482a96467c292519577d4f34406e5a474ed12acb Mon Sep 17 00:00:00 2001 From: Garrett Grolemund Date: Wed, 2 Oct 2024 15:48:39 -0500 Subject: [PATCH 4/6] Removes button for brownian app --- examples/brownian/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/brownian/README.md b/examples/brownian/README.md index e3605b8cd..d2b531f43 100644 --- a/examples/brownian/README.md +++ b/examples/brownian/README.md @@ -1,3 +1 @@ ## Hand-driven data exploration app - - From 7be0b643f60555eca96d05e54aa45ec1d284cd0b Mon Sep 17 00:00:00 2001 From: Garrett Grolemund Date: Wed, 2 Oct 2024 16:00:11 -0500 Subject: [PATCH 5/6] Removes deploy buttons from shiny chat apps (deployment requires openapi keys) --- examples/chat/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/chat/README.md b/examples/chat/README.md index eb2b59363..b0c2f4907 100644 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -10,12 +10,12 @@ To get started with an app that doesn't require an API key, see the `hello-world ## Apps -* [hello-world](hello-world): A simple chat app that echoes back the user's input. -* [playground](playground): A playground for testing out different chat models: `openai`, `claude`, and `google`. +* [hello-world](hello-world): A simple chat app that echoes back the user's input. +* [playground](playground): A playground for testing out different chat models: `openai`, `claude`, and `google`. * RAG - * [recipes](RAG/recipes): A simple recipe extractor chatbot that extracts recipes from URLs using the OpenAI API. + * [recipes](RAG/recipes): A simple recipe extractor chatbot that extracts recipes from URLs using the OpenAI API. * UI - * [clear](ui/clear): This example demonstrates how to clear the chat when the model changes. - * [dark](ui/dark): This example demonstrates Shiny Chat's dark mode capability. - * [dynamic](ui/dynamic): A basic example of dynamically re-rendering a Shiny Chat instance with different models. - * [sidebar](ui/sidebar): An example of placing a Shiny Chat instance in a sidebar (and having it fill the sidebar). + * [clear](ui/clear): This example demonstrates how to clear the chat when the model changes. + * [dark](ui/dark): This example demonstrates Shiny Chat's dark mode capability. + * [dynamic](ui/dynamic): A basic example of dynamically re-rendering a Shiny Chat instance with different models. + * [sidebar](ui/sidebar): An example of placing a Shiny Chat instance in a sidebar (and having it fill the sidebar). From d21de3cdda605701e9c40c045fc98e98bd8aca1c Mon Sep 17 00:00:00 2001 From: Garrett Grolemund Date: Wed, 2 Oct 2024 16:08:29 -0500 Subject: [PATCH 6/6] Removes inline argument from shy.ui.output_code --- examples/express/hold_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/express/hold_app.py b/examples/express/hold_app.py index e64c29490..b692f195d 100644 --- a/examples/express/hold_app.py +++ b/examples/express/hold_app.py @@ -25,4 +25,4 @@ def txt(): ui.input_slider("n", "N", 1, 100, 50) -shiny.ui.output_code("txt", inline=True) +shiny.ui.output_code("txt")