-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: main
Are you sure you want to change the base?
Conversation
mivasconcelos
commented
Mar 19, 2024
INKEEP_API_KEY = os.getenv('INKEEP_API_KEY') | ||
INKEEP_INTEGRATION_ID = os.environ.get('INKEEP_INTEGRATION_ID') |
There was a problem hiding this comment.
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
There was a problem hiding this 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; |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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]: |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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'] |
There was a problem hiding this comment.
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.