-
-
Notifications
You must be signed in to change notification settings - Fork 35
Add a setting to integrate the AI generated code in the AI answer directly into the file #111
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
Conversation
In Phantom mode, created a new setting to only integrate the AI generated code without its comments and other markdown syntax.
yaroslavyaroslav
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for the contribution to this long waited feature.
I'd love to merge your PR after a few minor style issues fixes.
|
|
||
| # clear modules cache if package is reloaded (after update?) | ||
| prefix = __package__ + '.plugins' # type: ignore # don't clear the base package | ||
| for module_name in [module_name for module_name in sys.modules if module_name.startswith(prefix)]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please revert all of these formatting changes, as they're not the subject of the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted this file. It should be fine now.
plugins/utils.py
Outdated
| import re | ||
|
|
||
|
|
||
| def extract_code_blocks(md_text: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add return type hint for that func to compline with the rest of the code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done it
| self.phantom_id: int | None = None | ||
| self.user_input = user_input | ||
| self.is_discardable: bool = ( | ||
| load_settings('openAI.sublime-settings') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes in this file are formatting ones, which are made b the rules which are differs from the ones that are set within this project .ruff linterconfig.
Could you please reformat the file with respect to that linter rules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine now, please let me know if there is anything else :)
Correct some formatting issues
Correct some formatting issues
Correct some formatting issues
yaroslavyaroslav
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, few last things to fix
| ) | ||
| from .plugins.worker_running_context import ( # noqa: E402, | ||
| OpenaiWorkerRunningContext, # noqa: F401 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bring back new line at the end of file. I expect that this file will be eliminated from within the PR completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got it
plugins/utils.py
Outdated
| pattern = re.compile(r"```(?:[^\n`]*)\n([\s\S]*?)```") | ||
|
|
||
| # Remove all inline blocks that the model may generate (i.e. code blocks that are inline with the text or that are single line) | ||
| filtered = re.sub(r"```([^\n]*?)```", "", md_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply linter for that new file also (it's "" instead of '' stuff mostly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've done it.
Correct some formatting issues
|
Sorry about all the formatting issues, I'm using the python-black plugin that reformats automatically everything with another style. Maybe next time can you share which plugin you use for auto formatting? That way next time I can use the same... |
|
Yeah, sure it's ST lsp-ruff plugin, which has to auto pick up .ruff rules stored in the root of the wd. Thank you once again for contribution, I'll release new version in PC shortly. |
In Phantom mode, created a new setting to only integrate the AI generated code without its comments and other markdown syntax. This new feature will extract from the AI generated answer the content of multiline code blocks when integrating the AI answer in a code file in any way. This will happen when the user will click on one of the following option (in phantom mode): Copy, Append, Replace, In New Tab.
The motivation behind this modification is to be able to directly generate code from the AI model and include it in the working file without all the AI comments and the markdown code block delimiters.