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

Add SQrL EXPLAIN command #22

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

mivasconcelos
Copy link

image

Comment on lines +18 to +19
INKEEP_API_KEY = os.getenv('INKEEP_API_KEY')
INKEEP_INTEGRATION_ID = os.environ.get('INKEEP_INTEGRATION_ID')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still need to be set up

Copy link
Collaborator

@kesmit13 kesmit13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several comments here. Also, you should run pip install pre-commit and run pre-commit install in your clone so that the pre-commit checks run. I see some formatting that's off from the rules here.


class SqrlExplain(SQLHandler):
"""
SQRL EXPLAIN string_value;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should change string_value to something like query if a query string is expected here. This grammar is printed as part of the help information, so the more descriptive the labels are, the better.

string_value = '<string-value>'

"""
INKEEP_API_KEY = os.getenv('INKEEP_API_KEY')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use os.environ.get call for both of these.

INKEEP_API_KEY = os.getenv('INKEEP_API_KEY')
INKEEP_INTEGRATION_ID = os.environ.get('INKEEP_INTEGRATION_ID')

def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if the results should be returned as a result set rather than being printed. I don't know what the result will be used for, but printing is kind of a dead end since it just goes to stdout and it's hard to capture if needed.


def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
prompt = "Explain me this SQL query:" + params['string_value']
apiUrl = "https://api.inkeep.com/v0/chat_sessions/chat_results"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a class variable as well so it can be changed easier for testing new API versions.


def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
prompt = "Explain me this SQL query:" + params['string_value']
apiUrl = "https://api.inkeep.com/v0/chat_sessions/chat_results"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PEP-8 style variable names: api_url.

apiUrl,
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + INKEEP_API_KEY,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be self.INKEEP_API_KEY, correct?

'Authorization': 'Bearer ' + INKEEP_API_KEY,
},
json={
"integration_id": INKEEP_INTEGRATION_ID,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

INKEEP_INTEGRATION_ID = os.environ.get('INKEEP_INTEGRATION_ID')

def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
prompt = "Explain me this SQL query:" + params['string_value']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check here to make sure the API keys are not None. If they are, print a message to stderr that they need to be set to use this command.

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

Successfully merging this pull request may close these issues.

2 participants