Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: review database and schema usage on tool configuration #46

Open
sfc-gh-twhite opened this issue Nov 20, 2024 · 1 comment
Open

Comments

@sfc-gh-twhite
Copy link
Collaborator

# Cortex Analyst Config
analyst_config = {
    "semantic_model": "sp500_semantic_model.yaml",
    "stage": "ANALYST",
    "service_topic": "S&P500 company and stock metrics",
    "data_description": "a table with stock and financial metrics about S&P500 companies ",
    "snowflake_connection": session,
}

sp500 = CortexAnalystTool(**analyst_config)

If the user was to fully qualify the STAGE, such as "stage": "CUBE_TESTING.PUBLIC.ANALYST", we hit an unhandled exception: Caught unhandled exception: Unexpected error during Cortex gateway Tool request: Stage CUBE_TESTING.PUBLIC.CUBE_TESTING.PUBLIC.ANALYST does not exist or is not authorized.

We need to either document this behavior or internally handle the cases where a user fully qualifies the stage.

I suspect this will have implications on using tools when the connection context changes.

@sfc-gh-twhite
Copy link
Collaborator Author

This presents a situation where a user may use a different database or schema and will likely attempt to fully qualify the stage. This wouldn't work. The only way to get around such a predicament today would be to have another instance of a Session class available set to the particular database and schema where the stage housing the semantic file exists.

I really think we'll need to address how we're referencing the semantic_model_file here:

def _prepare_analyst_request(self, prompt):
data = {
"messages": [
{"role": "user", "content": [{"type": "text", "text": prompt}]}
],
"semantic_model_file": f"@{self.connection.database}.{self.connection.schema}.{self.STAGE}/{self.FILE}",
}

One option would be to support fully qualifying the stage path. Another option might be to support a database and a schema argument to initialize the CortexAnalystTool class. Both database and schema could be optional, especially if the stage is already in the current context.

cc: @sfc-gh-alherrera

@sfc-gh-twhite sfc-gh-twhite changed the title ENH: Review database/schema usage on tool configuration fix: review database and schema usage on tool configuration Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant