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

Improve content generation prompt to reduce over-generation #16333

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

nathansobo
Copy link
Contributor

I focused on cases where we're inserting doc comments or annotations above symbols.

I added 5 new examples to the content generation prompt, covering various scenarios:

  1. Inserting documentation for a Rust struct
  2. Writing docstrings for a Python class
  3. Adding comments to a TypeScript method
  4. Adding a derive attribute to a Rust struct
  5. Adding a decorator to a Python class

These examples demonstrate how to handle different languages and common tasks like adding documentation, attributes, and decorators.

To improve context integration, I've made the following changes:

  1. Added a transform_context_range that includes 3 lines before and after the transform range
  2. Introduced rewrite_section_prefix and rewrite_section_suffix to provide more context around the section being rewritten
  3. Updated the prompt template to include this additional context in a separate code snippet

Release Notes:

  • Reduced instances of over-generation when inserting docs or annotations above a symbol.

I focused on cases where we're inserting doc comments or annotations
above symbols.

I added 5 new examples to the content generation prompt, covering various scenarios:

1. Inserting documentation for a Rust struct
2. Writing docstrings for a Python class
3. Adding comments to a TypeScript method
4. Adding a derive attribute to a Rust struct
5. Adding a decorator to a Python class

These examples demonstrate how to handle different languages and common tasks like adding documentation, attributes, and decorators.

To improve context integration, I've made the following changes:

1. Added a `transform_context_range` that includes 3 lines before and after the transform range
2. Introduced `rewrite_section_prefix` and `rewrite_section_suffix` to provide more context around the section being rewritten
3. Updated the prompt template to include this additional context in a separate code snippet
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Aug 16, 2024
@nathansobo nathansobo merged commit ad44b45 into main Aug 16, 2024
9 checks passed
@nathansobo nathansobo deleted the fix-over-generation branch August 16, 2024 04:20

Immediately start with the following format with no remarks:

```
\{{REWRITTEN_CODE}}
{{REWRITTEN_CODE}}
Copy link
Contributor

Choose a reason for hiding this comment

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

due to this no longer being escaped, this section will get rendered away by handlebars, right? is that intended?

jvmncs added a commit that referenced this pull request Aug 16, 2024
Fixed the output format section of the content_prompt.hbs template
getting rendered away by handlebars. Also fixed a leftover hardcoded
"Rust" in the rewrite section snippet. (follow-up to #16333)

Release Notes:

- N/A
nathansobo added a commit that referenced this pull request Aug 16, 2024
I focused on cases where we're inserting doc comments or annotations
above symbols.

I added 5 new examples to the content generation prompt, covering
various scenarios:

1. Inserting documentation for a Rust struct
2. Writing docstrings for a Python class
3. Adding comments to a TypeScript method
4. Adding a derive attribute to a Rust struct
5. Adding a decorator to a Python class

These examples demonstrate how to handle different languages and common
tasks like adding documentation, attributes, and decorators.

To improve context integration, I've made the following changes:

1. Added a `transform_context_range` that includes 3 lines before and
after the transform range
2. Introduced `rewrite_section_prefix` and `rewrite_section_suffix` to
provide more context around the section being rewritten
3. Updated the prompt template to include this additional context in a
separate code snippet

Release Notes:

- Reduced instances of over-generation when inserting docs or
annotations above a symbol.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants