ChatSnowflake

ChatSnowflake(
    system_prompt=None,
    model=None,
    turns=None,
    connection_name=None,
    account=None,
    user=None,
    password=None,
    private_key_file=None,
    private_key_file_pwd=None,
    kwargs=None,
)

Chat with a Snowflake Cortex LLM

https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions

Prerequisites

Python requirements

ChatSnowflake, requires the snowflake-ml-python package: pip install "chatlas[snowflake]".

Snowflake credentials

Snowflake provides a handful of ways to authenticate, but it’s recommended to use key-pair auth to generate a private_key_file. It’s also recommended to place your credentials in a connections.toml file.

This way, once your credentials are in the connections.toml file, you can simply call ChatSnowflake(connection_name="my_connection") to authenticate. If you don’t want to use a connections.toml file, you can specify the connection parameters directly (with account, user, password, etc.).

Parameters

Name Type Description Default
system_prompt Optional[str] A system prompt to set the behavior of the assistant. None
model Optional[str] The model to use for the chat. The default, None, will pick a reasonable default, and warn you about it. We strongly recommend explicitly choosing a model for all but the most casual use. None
turns Optional[list[Turn]] A list of turns to start the chat with (i.e., continuing a previous conversation). If not provided, the conversation begins from scratch. Do not provide non-None values for both turns and system_prompt. Each message in the list should be a dictionary with at least role (usually system, user, or assistant, but tool is also possible). Normally there is also a content field, which is a string. None
connection_name Optional[str] The name of the connection (i.e., section) within the connections.toml file. This is useful if you want to keep your credentials in a connections.toml file rather than specifying them directly in the arguments. https://docs.snowflake.com/en/developer-guide/snowpark/python/creating-session#connect-by-using-the-connections-toml-file None
account Optional[str] Your Snowflake account identifier. Required if connection_name is not provided. https://docs.snowflake.com/en/user-guide/admin-account-identifier None
user Optional[str] Your Snowflake user name. Required if connection_name is not provided. None
password Optional[str] Your Snowflake password. Required if doing password authentication and connection_name is not provided. None
private_key_file Optional[str] The path to your private key file. Required if you are using key pair authentication. https://docs.snowflake.com/en/user-guide/key-pair-auth None
private_key_file_pwd Optional[str] The password for your private key file. Required if you are using key pair authentication. https://docs.snowflake.com/en/user-guide/key-pair-auth None
kwargs Optional[dict[str, str | int]] Additional keyword arguments passed along to the Snowflake connection builder. These can include any parameters supported by the snowflake-ml-python package. https://docs.snowflake.com/en/developer-guide/snowpark/python/creating-session#connect-by-specifying-connection-parameters None