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

How to read the selected code and send it as part of the message/prompt. #115

Open
manzoo79 opened this issue Nov 26, 2024 · 2 comments
Open

Comments

@manzoo79
Copy link

I would like to send the selected code as part of the prompt, when communicating with the GitHub model. Can you please share an example?

@gr2m
Copy link
Collaborator

gr2m commented Nov 26, 2024

I'm not sure if the currently selected code is sent in the .copilot_references property of a message. Once we know that it is, we can add types to make access to it more resilient.

Can you share a raw message body that includes selected code data?

@ledoyen
Copy link

ledoyen commented Dec 6, 2024

As of today, when in VS code, it is possible to add the current selection to contextual information using the Image icon.

It will then be added as a little label on the chat box
Image

This results in an item of the form added to the copilot_references array:

{
  "type": "client.selection",
  "data": {
    "content": "selection content with line break and tabs escaped with \\n & \\t",
    "end": {
      "col": 5,
      "line": 51
    },
    "start": {
      "col": 3,
      "line": 44
    }
  },
  "id": "+page.svelte", // Note that this is not the absolute path of the file, and there is currently no information to get that
  "is_implicit": false,
  "metadata": {
    "display_name": "",
    "display_icon": "",
    "display_url": ""
  }
}

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

No branches or pull requests

3 participants