Quickstart

Prerequisites

Before starting this tutorial, make sure you have:

  1. Installed Sema4.ai Studio and connected it to Snowflake
  2. Installed the Sema4.ai SDK extensions
  3. Completed the Data setup guide to create the required database objects and load sample data
  4. The following Snowflake requirements:
    • Admin level access to a Snowflake account
    • Key-pair authentication set up for your Snowflake user
    • Cortex AI LLM usage granted to your account/role (and cross-region inference enabled in case your Snowflake account is in a region where it's needed, read more here (opens in a new tab))

Import an existing agent

You'll learn how to:

  1. Open an agent package using your IDE
  2. Publish an agent to Sema4.ai Studio
  3. Connect Studio to your Snowflake data sources
  4. Connect your agent to Snowflake Cortex Analyst
  5. Test your agent locally

Open Sema4.ai Studio

We'll get started using Sema4.ai Studio. Open it up and take a moment to look around the Studio. These are the main tabs you'll be using:

  • Agents - This is where you'll see all your agents, create and manage agents.
  • Actions - Home of the actions that your agents can use. We've included a gallery of pre-built actions to common platform (tagged with prefix Sema4.ai) and you can also create your own (will be tagged with prefix My Actions).
  • Data Sources - Connections to data sources that you can use in your agents.
Sema4.ai Studio - Ready to build agents!
Sema4.ai Studio - Ready to build agents!

Download an agent project

We'll start by downloading an agent pacakge zip file from here (opens in a new tab). Once downloaded, unzip the file and open it in your IDE.

$ unzip quickstart-oil-and-gas.zip -d oil-and-gas
$ cd oil-and-gas
$ code .

This will open the agent package in your IDE.

When downloading and unzipping, choose a directory outside of ~/Downloads. Some IDEs have security restrictions that prevent opening projects from the Downloads folder.

Open an agent package in your IDE

  1. Open the VSCode extension.
  2. Expand the MyActions and oil-and-gas sections to see the data actions included in the project.
Agent package
Agent package

Click any of the actions, then click on the Open Action button to see the Python code used to create the action.

Open action
Open action

The @query decorator exposes this function to the agent. The docstring helps the agent understand how and when it should be used, and the parameters with their type hints (e.g. wellName: str) informs the agent what parameters are required to invoke this data action.

Publish an agent to Sema4.ai Studio

Agents can be published to Sema4.ai Studio in a single click. Scroll down to the bottom of the agent package section and under Commands, click Publish to Sema4.ai Studio. This will build your agent package and automatically publish it when finished.

Publish agent
Publish agent

Publishing your agent may take a few minutes to complete.

Configure the agent

  1. Open Sema4.ai Studio - you should automatically be redirected to the Agents tab where you can see your agent importing.
  2. Once your agent is imported, you'll automatically see the agent import screen where we need to configure it to connect to your Snowflake data sources and Cortex Analyst.
Agent imported
Agent imported

Configure the Snowflake Cortex Analystaction

  1. Under Actions, click the Configure button for the Snowflake Cortex Analyst action.

Enter the following information:

ConfigurationValue
DatabaseOIL_AND_GAS
SchemaPUBLIC
Semantic model file@OIL_AND_GAS.PUBLIC.CORTEX_ANALYST/oil_gas.yaml
WarehouseSEMA4_DEMO_WH

You can click the icon in any input field to reveal its contents.

  1. Click Confirm when done.

Configure the Data Source

  1. Under Data Sources, click the Add new Connection Details link to add a new connection to your Snowflake data.
  2. In the pop-up window, enter the following information:
SettingValue
NameOil & Gas
DescriptionQuickstart Oil & Gas Production Results
EngineSnowflake
CredentialsLinked Account - (Your Snowflake account name)
WarehouseSEMA4_DEMO_WH
DatabaseOIL_AND_GAS
SchemaPUBLIC
  1. Click Save Connection when done.
Data source
Data source
  1. Click Update in the lower-left corner to start your agent.

Once deployed, you can start working with your agent.

Use your agent

Try asking the agent a few questions to see how it uses both Cortex Analyst and the data actions to answer specific questions.

Create a new Chat for each of these sections to keep your conversations organized and in-context.

Exploration

Show me the top 5 wells

Show me the production history for TEDDY FEDERAL 12X-5F

Show me the map and file links for this well

Specific Well analysis

Can you show me the monthly production data for Porter 26-35 4H

Can you show me the exponential decline curve for this well using 2024 data?

Show me the map link for this well

Show me all the wells within 200 meters of this well

How many wells does Grayson operate?

Show me a heatmap of wells per field

Complex Analysis

Can you show me the top 10 with the most improved month over month water-to-oil ratio in 2024?

Show me the wells with a 3:1 oil-to-gas ratio

Recommended resources

Congratulations on making it through this quickstart! We hope you enjoyed it, and to learn more about each of the specific steps you followed, feel free to review the Step-by-step walkthrough.