Skip to content

Commit 92720a4

Browse files
authored
Merge pull request #1298 from tx-smitht/main
Created the snowpark profile for letting open interpreter connect to a user's snowflake account
2 parents a145349 + e41f121 commit 92720a4

File tree

1 file changed

+87
-0
lines changed
  • interpreter/terminal_interface/profiles/defaults

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
### OPEN INTERPRETER CONFIGURATION FILE
2+
3+
# Remove the "#" before the settings below to use them.
4+
5+
# LLM Settings
6+
llm:
7+
model: "gpt-4-turbo"
8+
temperature: 0
9+
# api_key: ... # Your API key, if the API requires it
10+
# api_base: ... # The URL where an OpenAI-compatible server is running to handle LLM API requests
11+
# api_version: ... # The version of the API (this is primarily for Azure)
12+
# max_output: 2500 # The maximum characters of code output visible to the LLM
13+
14+
# Computer Settings
15+
computer:
16+
import_computer_api: True # Gives OI a helpful Computer API designed for code interpreting language models
17+
18+
# Custom Instructions
19+
custom_instructions: '''
20+
You are going to be connecting to Snowflake, the cloud data platform. You can use the Snowpark API to interact with Snowflake. Here are some common tasks you might want to do:
21+
- Connect to Snowflake
22+
- Run a query
23+
24+
You can use the Snowpark API to do these tasks. To create a session with snowpark, you have to first import the session object from snowpark and pandas, like so:
25+
```python
26+
from snowflake.snowpark import Session
27+
import pandas as pd
28+
```
29+
If this doesnt work, you may need to run the following commands to install snowpark and pandas:
30+
```python
31+
!pip install snowflake-snowpark-python
32+
!pip install pandas
33+
!pip install "snowflake-snowpark-python[pandas]"
34+
!pip install "snowflake-connector-python[pandas]"
35+
```
36+
37+
Then, you can create a dictionary with the necessary connection parameters and create a session. You will access these values from the
38+
environment variables:
39+
```python
40+
# Retrieve environment variables
41+
snowflake_account = os.getenv("SNOWFLAKE_ACCOUNT")
42+
snowflake_user = os.getenv("SNOWFLAKE_USER")
43+
snowflake_password = os.getenv("SNOWFLAKE_PASSWORD")
44+
snowflake_role = os.getenv("SNOWFLAKE_ROLE")
45+
snowflake_warehouse = os.getenv("SNOWFLAKE_WAREHOUSE")
46+
snowflake_database = os.getenv("SNOWFLAKE_DATABASE")
47+
snowflake_schema = os.getenv("SNOWFLAKE_SCHEMA")
48+
49+
# Create connection parameters dictionary
50+
connection_parameters = {
51+
"account": snowflake_account,
52+
"user": snowflake_user,
53+
"password": snowflake_password,
54+
"role": snowflake_role,
55+
"warehouse": snowflake_warehouse,
56+
"database": snowflake_database,
57+
"schema": snowflake_schema,
58+
}
59+
60+
# Create a session
61+
session = Session.builder.configs(connection_parameters).create()
62+
```
63+
You should assume that the environment variables have already been set.
64+
You can run a query against the snowflake data by using the session.sql() method. Then, you can turn the snowpark dataframe
65+
that is created into a pandas dataframe for use in other processes. Here is an example of how you can run a query:
66+
```python
67+
# Run a query
68+
query = "<your query goes here>"
69+
snowpark_dataframe = session.sql(query)
70+
71+
# Convert the snowpark dataframe to a pandas dataframe
72+
df = snowflake_dataframe.to_pandas()
73+
```
74+
75+
You can now use this dataframe to do whatever you need to do with the data.
76+
77+
''' # This will be appended to the system message
78+
79+
# General Configuration
80+
# auto_run: False # If True, code will run without asking for confirmation
81+
# safe_mode: "off" # The safety mode for the LLM — one of "off", "ask", "auto"
82+
# offline: False # If True, will disable some online features like checking for updates
83+
# verbose: False # If True, will print detailed logs
84+
# multi_line: False # If True, you can input multiple lines starting and ending with ```
85+
86+
# Documentation
87+
# All options: https://docs.openinterpreter.com/settings

0 commit comments

Comments
 (0)