Content-Length: 272318 | pFad | https://github.com/stacklok/codegate/pull/1202

42 Strip attachments from copilot messages when handling the CLI commands by jhrozek · Pull Request #1202 · stacklok/codegate · GitHub
Skip to content

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

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

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 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.

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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/stacklok/codegate/pull/1202

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy