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

Including additional context in message #829

Open
michaelchia opened this issue Jun 12, 2024 · 0 comments
Open

Including additional context in message #829

michaelchia opened this issue Jun 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@michaelchia
Copy link
Collaborator

Problem

I would like to have more context passed into the message. In addition to the selected text, it would also include data like the contents of the active file, cursor position, active kernel etc. This will allow chat handlers to operate with more context. I will provide details of exact information in the Proposed Solution section.

This is an enhancement request inspired by what was added in #828. I am so glad @dlqqq added this as it was pretty much exactly the direction I was hoping for.

For context, a couple weeks ago, I actually hacked my way into implementing a patch that is pretty much what was implemented in /fix which also includes a cell toolbar button to trigger it.

In my implementation, in addition to the cell stderr, I also submit the entire notebook contents and the kernel id as well. Specifically, I submit the active cell id, the entire notebook data (notebook.model.toJSON()), and the its kernel id (if active kernel). The chat handler will extract the active cell and error using the active cell id and will also include the previously ran cells. This is inferred by filtering out all code cells before active cell that have a lower execution count (not a perfect logic but approximate enough). Kernel ID currently not used, but idea was to extract some variable information that may help the debugging.

Proposed Solution

Building upon what was done in #828. The idea of adding active cell text and error to the message can be generalised further to include more information in the message.

Context data

I propose the following information be included in the context (without opinion on exact data model):
For active notebook:

  • filepath
  • active cell
  • notebook data (all cell source, type, outputs: stdout/stderr, execution count)
  • kernel id
  • selection / cursor position/s

For active file editor:

  • filepath
  • file content
  • selection / cursor position/s

Possible enhancements

Selected text as context

Instead of pasting the selected text in the user message, include it as just another context item as above. This will allow chat handlers to differentiate selected text and something the user copypasted.

Additional benefit is it would help clean up the UI as sometimes the selected text can be quite long and end up filling up the chat. See secontion on UI below for how the user is made known of what is selected.

Config

Users should be able to configure what context is submitted. Right now, whether the selection is included is configured below the input box. Perhaps a separate tab or a dropdown may be required if the options grow.

UI

What is included in the context should be shown to the user. There are two possible ways to do this.

  1. Show what context was submitted in a dropdown in the user message.
  2. Push responsibility to chathandler to add what context was used in a dropdown in the agent message.
@michaelchia michaelchia added the enhancement New feature or request label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant