A simple Streamlit in Snowflake (SiS) app that demonstrates Snowflake Cortex AI functions for text generation using large language models.
This app showcases how to call Cortex AI functions directly from a Streamlit app running inside Snowflake. It uses the ai_complete() function to generate text completions powered by LLMs (e.g. claude-4-sonnet).
simple-streamlit-app/
├── streamlit_app.py # Main app: prompt pills, editable prompt, ai_complete() call, response + JSON output
├── requirements.txt # Python dependencies (snowflake-snowpark-python)
├── README.md # This file
└── .streamlit/
└── config.toml # Streamlit theme / app configuration
- A Snowflake account with Cortex AI enabled
- The
snowflake-snowpark-pythonpackage (listed inrequirements.txt)
- Open Snowsight and navigate to Projects → Streamlit.
- Click + Streamlit App and give it a name (e.g.
CORTEX_DEMO). - Select a warehouse, database, and schema for the app.
- In the editor, upload or paste the contents of
streamlit_app.pyas the main file. - In the Packages panel, add
snowflake-snowpark-python(or leave it at the default — it is pre-installed in SiS). - Click Run to launch the app.
Note: The app uses
st.connection("snowflake")which resolves automatically when running inside Snowflake — no extra credentials or secrets are needed.
To run against a Snowflake account from your local machine:
-
Create a
.streamlit/secrets.tomlfile with your Snowflake connection details:[connections.snowflake] account = "<your_account>" user = "<your_user>" password = "<your_password>" warehouse = "<your_warehouse>" database = "<your_database>" schema = "<your_schema>"
-
Install dependencies:
pip install streamlit snowflake-snowpark-python
-
Run the app:
streamlit run streamlit_app.py