Skip to content

Modify \llm to use either + or - modifiers. #227

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

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

Conversation

amjith
Copy link
Member

@amjith amjith commented May 26, 2025

Description

The \llm command now has three modes. Succinct, Regular and Verbose.

Succinct = \llm- - This will return just the sql query. No explanation.
Regular = \llm - This will return just the sql query and the explanation.
Verbose = \llm+ - This will print the prompt sent to the LLM and the sql query and the explanation.

Checklist

  • I've added this contribution to the CHANGELOG.md file.

@amjith amjith requested a review from kracekumar May 26, 2025 00:28
@amjith amjith force-pushed the amjith/llm-improvements branch from aa90344 to 1efcd02 Compare May 26, 2025 00:29
@@ -86,7 +86,7 @@ def suggest_type(full_text, text_before_cursor):

def suggest_special(text):
text = text.lstrip()
cmd, _, arg = parse_special_command(text)
cmd, mode, arg = parse_special_command(text)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are not using the variable, why assign it to a name?

@@ -293,12 +292,12 @@ def is_llm_command(command) -> bool:
"""
Is this an llm/ai command?
"""
cmd, _, _ = parse_special_command(command)
cmd, mode, arg = parse_special_command(command)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are not using these variables, why assign a name?

"""
raw, _, arg = sql.partition(" ")
is_verbose = raw.endswith("+")
is_succinct = raw.endswith("-")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we validate for llm+- and other invalid/unsupported commands?

Copy link
Member Author

Choose a reason for hiding this comment

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

What did you have in mind? I could see someone calling \llm* Question or \llm= Question. It'll just ignore unknown chars and treat them as regular verbosity.

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to cover two cases: more than 1 special character and unknown special character. Ideally, incorrect usage should not pass silently. What do you think?

"""
raw, _, arg = sql.partition(" ")
is_verbose = raw.endswith("+")
is_succinct = raw.endswith("-")
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to cover two cases: more than 1 special character and unknown special character. Ideally, incorrect usage should not pass silently. What do you think?

is_verbose = raw.endswith("+")
is_succinct = raw.endswith("-")
# strip out any + or - modifiers to get the actual command name
command = raw.strip().rstrip("+-")
Copy link
Contributor

@kracekumar kracekumar May 27, 2025

Choose a reason for hiding this comment

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

We may need to be strict here to check command == llm.

Following are some cases

>>> raw ="llm+-"
>>> raw.strip().rstrip("+-")
'llm'
>>> raw ="llm*"
>>> raw.strip().rstrip("+-")
'llm*'

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