Skip to content

Conversation

@kracekumar
Copy link
Contributor

Description

  1. Since llm command fetches the schema of the database, creates a prompt and then invokes the llm command with the prompt. add a couple of log lines to indicate to user about the progress.
  2. The PR measures entire end to end invocation of the command. The output message is different for run_external_cmd that is directly invoked and invoked via sql_using_llm.
  3. I'm happy to modify the messages or colors to make more useful. I have skipped using emojis and sticked with simple useful messages.
  4. Example Outputs:
/Users/kracekumar/code/mcp-chatbot/test.db> \llm+ "Show only the top 5 results"
Preparing schema information to feed the llm
Invoking llm command with schema information
Received response from the llm command
LLM Reponse:
...
Explanation:

- We join `people`, `groups`, and `contact_groups` tables to get the required data.
- We use a window function (`ROW_NUMBER()`) to assign a unique number to each person based on their contact_id and group_id. This allows us to sort the results in descending order of these fields.
- The outer query then selects only the top 5 people by filtering `row_num` to be less than or equal to 5.

...

Explanation:

- This query simply counts the number of groups in the database, which represents the total number of people in contact groups.

---
Time: 6.07 seconds
....
/Users/kracekumar/code/mcp-chatbot/test.db> \llm+ -m codellama -c "Show only the top 5 results"
Calling llm command
LLM Reponse:
...
Explanation:

- We join `people`, `groups`, and `contact_groups` tables to get the required data.
- We use a window function (`ROW_NUMBER()`) to assign a unique number to each person based on their contact_id and group_id. This allows us to sort the results in descending order of these fields.
- The outer query then selects only the top 5 people by filtering `row_num` to be less than or equal to 5.
...

Explanation:

- This query simply counts the number of groups in the database, which represents the total number of people in contact groups.

---
Time: 15.61 seconds

Checklist

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

mock_sql_using_llm.assert_called()
assert context == ""
assert sql == "SELECT 1;"
assert isinstance(duration, float)
Copy link
Member

Choose a reason for hiding this comment

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

Hah. That's clever. I typically do assert duration > 0.0 but this works too. :)

Copy link
Member

@amjith amjith left a comment

Choose a reason for hiding this comment

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

Nicely done. 🚀

@amjith amjith merged commit 1657070 into dbcli:main Feb 24, 2025
7 checks passed
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