This repository shows you how to build a simple chat app using Snowflake's API.
curl "https://[ACCOUNT-IDENTIFIER].snowflakecomputing.com/api/v2/cortex/inference:complete" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN" \
-d '{
"model": "claude-3-5-sonnet",
"messages": [
{
"role": "user",
"content": "Write me a one line poem about Snowflake"
}
]
}'
Snowflake's API is compatible with OpenAI's spec
-
Sign up for a new Snowflake account here. Activate your account by e-mail (see screenshot below), pick a username and password, and you should see a welcome screen.
Note: if you can't find your login info, search your inbox for an e-mail from "Snowflake Computing".
-
Generate a Personal Access Token (PAT) -- this is your API key -- by visiting Authentication Settings. Be sure to set the network policy exception for easy weekend hacking:
-
Find your account identifier by clicking on your name in the bottom left corner of Snowflake's UI, and selecting
Connect a tool to Snowflake:
-
That's it! Run the curl command in your terminal and observe the streaming output
-
Clone this repo.
-
Sign up for a new Snowflake account here. Activate your account by e-mail (see screenshot below), pick a username and password, and you should see a welcome screen.
Note: If you can't find your login info, search your inbox for an e-mail from "Snowflake Computing".
-
Generate a Personal Access Token (PAT) -- this is your API key -- by visiting Authentication Settings. Be sure to set the network policy exception for easy weekend hacking:
-
Click on your name in the bottom left corner, and select
Connect a tool to Snowflake:
-
Use the information in the connect dialog to fill in your
secrets.tomlfile:
[snowflake] account = "[Account Identifier]" user = "[User Name]" api_key = "[Paste in your Personal Access Token here]" role = "[Role]" host = "[Account/Server URL]" -
Run
pip install -r requirements.txtto make sure you have all the dependencies working. -
Run
streamlit run streamlit.appand you should see a simple chat app ready to chat with you! Try changing the model used:mistral-large2,claude-3-5-sonnetorllama3.1-70band compare the chat interaction!