Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Strip attachments from copilot messages when handling the CLI commands #1202

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Mar 4, 2025

Copilot sends files in the context in the following format:

<attachment>
file
<attachment>
user query

Fixes: #1061

JAORMX
JAORMX previously approved these changes Mar 4, 2025
Returns:
Optional[re.Match[str]]: A regex match object if command is found, None otherwise
"""
cleaned_text = re.sub(r'<attachment>.*</attachment>', '', last_user_message_str, flags=re.DOTALL)
Copy link
Contributor

Choose a reason for hiding this comment

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

optimization: pre-declare and pre-compile each regular expression in the constructor or even globally so this function would only need to evaluate the regex as opposed to compile+evaluate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let's do it separately for all the regexes here. We should also move the client helpers to the client interface.

Copilot sends files in the context in the following format:
```
<attachment>
file
<attachment>
user query
```

Fixes: #1061
@jhrozek jhrozek merged commit 08c0111 into main Mar 4, 2025
11 checks passed
@jhrozek jhrozek deleted the copilot_version branch March 4, 2025 20:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

codegate cli doesn't work in copilot if context is selected
2 participants