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

[Question] How can I get in my agent the user code or at least the file reference (file path and line numbers) ? #3

Open
eylonmalin opened this issue Nov 20, 2024 · 2 comments
Labels
question Further information is requested

Comments

@eylonmalin
Copy link

Question
How can I get in my agent the user code or at least the file reference (file path and line numbers) ?

Context
I want to get the user context in my agent

Additional context
I'm building a new agent and need the user context

@eylonmalin eylonmalin added the question Further information is requested label Nov 20, 2024
@Houndie
Copy link
Collaborator

Houndie commented Nov 21, 2024

Hi @eylonmalin!

I'm not 100% sure on your question, so I might be answering something you're not asking.

If you're talking about getting information about the current user, you can use the value in the X-GITHUB-TOKEN header to make calls against GitHub's API on behalf of the user.

If you're talking about "what is the user currently doing" (for example what repositories do they have open), you can find that information in the request body, messages[*].copilot_references. Note that what references get sent are client-dependent!

Let me know if this answers your question.

@pablomayobre
Copy link

pablomayobre commented Dec 6, 2024

This gives you file contents but not file path, is there a way to get the full file path?

Example here:

{
    "agent": "my-copilot-extension",
    "copilot_skills": [],
    "copilot_thread_id": "xxx",
    "frequency_penalty": 0,
    "functions": null,
    "max_tokens": 4096,
    "messages": [
      {
        "content": "hey",
        "copilot_confirmations": null,
        "copilot_references": [
          {
            "data": {
              "content": "some file contents",
              "language": "yaml"
            },
            "id": "basename.yml",
            "is_implicit": true,
            "metadata": {
              "display_icon": "",
              "display_name": "",
              "display_url": ""
            },
            "type": "client.file"
          },
          {
            "data": {
              "content": "  selector:\n",
              "end": { "col": 0, "line": 16 },
              "start": { "col": 0, "line": 15 }
            },
            "id": "basename.yml",
            "is_implicit": true,
            "metadata": {
              "display_icon": "",
              "display_name": "",
              "display_url": ""
            },
            "type": "client.selection"
          },
          {
            "data": {
              "commitOID": "",
              "description": "",
              "id": 630055225,
              "languages": null,
              "name": "my-repository",
              "ownerLogin": "my-org",
              "ownerType": "",
              "readmePath": "",
              "ref": "",
              "refInfo": { "name": "", "type": "" },
              "type": "repository",
              "visibility": ""
            },
            "id": "my-org/my-repository",
            "is_implicit": false,
            "metadata": {
              "display_icon": "",
              "display_name": "",
              "display_url": ""
            },
            "type": "github.repository"
          }
        ],
        "role": "user"
      }
    ],
    "model": "",
    "presence_penalty": 0,
    "response_format": null,
    "stop": null,
    "temperature": 0.1,
    "tools": null,
    "top_p": 1
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants