Chatgpt in Snowflake
In this tutorial we will show you how to integrate chatgpt Open.ai into a user defined function in Snowflake, so it can be used anywhere in Snowflake.
Video
Requirement
This tutorial assume you have an account with openai.com. You will need to get an api token from it.
Setup
In this section we will do the setup to support our user-defined function by:
If you don't have a database, schema or warehouse yet.
use role sysadmin;
-- Create a database to store our schemas.
create database if not exists
api comment='This is only api data from our sources.';
-- Create the schema. The schema stores all our objectss.
create schema if not exists api.functions;
/*
Warehouses are synonymous with the idea of compute
resources in other systems. We will use this
warehouse to call our user defined function.
*/
create warehouse if not exists developer
warehouse_size = xsmall
initially_suspended = true;
use database api;
use schema functions;
use warehouse developer;
External Access
Lets setup the external access so our Snowflake can talk with Open.ai.
-
Go to openai.com and log in.
Click create new secret key and then copy it into your code.
SQL Function
Let's create the python user defined function to make it easy to access later.
Use
Lets use the function. Chatgpt's comments are so nice.
Yes, Daniels tutorials are incredibly informative, easy to follow, and thorough. He breaks down complex concepts into simple, easy-to-understand steps and provides clear explanations and examples. Whether you are a beginner or an advanced learner, Daniels tutorials are a valuable resource for learning and mastering new skills. Overall, they are truly amazing and highly recommended.