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

Multiline response parsing #56

Closed
claygorman opened this issue Jul 6, 2024 · 8 comments
Closed

Multiline response parsing #56

claygorman opened this issue Jul 6, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@claygorman
Copy link

claygorman commented Jul 6, 2024

Feature request

I think it would be helpful to handle newline output from the response.

Why?

To get clearer more robust message structure.

Alternatives

No response

Additional context

I love the work done on this library by the way! good work. Currently my response for the commit message is a single line.

Notes:

  • using -c to copy to clipboard
  • using openai gpt-4o
  • using custom prompt: "Prepend fix: to the first line in lowercase. Avoid overly verbose descriptions or unnecessary details. Start with a short sentence in imperative form, no more than 50 characters long. Then leave an empty line and continue with a more detailed explanation. Write only one sentence for the first part, and two to five sentences at most for the detailed explanation. Use bullet points for multiple changes when possible."

My prompt should generate something like

fix: update Node.js version to 20.15.0 in Dockerfile

- Updated Node.js version from 20.13.1 to 20.15.0 in the Dockerfile.
- Ensures consistency and compatibility with the specified Node.js version
@tak-bro
Copy link
Owner

tak-bro commented Jul 8, 2024

@claygorman Thanks for posting the feature request.
I agree with the need for that too.

Can I see one of the gpt-4o response?
You don't have to upload your diff content.
I just want to see the response from gpt.

You can log it below command.
aicommit2 config set logging=true.
After setting up, you can check it in the ~/.aicommit2_log folder.

@tak-bro tak-bro self-assigned this Jul 8, 2024
@tak-bro tak-bro added the enhancement New feature or request label Jul 8, 2024
@claygorman
Copy link
Author

hey sure no problem. Here is what I got when i cat out the top of the file aic2_2024-07-08_15:41:07_4e2cff4233e264bb.log

[OPEN AI Response]
fix: update panel spec and panels to return 10 instead of null- Updated panelSpecs function to return 'Error in panel spec 10' instead of 'Error in panel spec'.- Updated panels function to return 'panels: 10' instead of 'panels: null'.


[AICommit2 Prompt]
..........

when formatted by hand I fix it to look like this

fix: update panel spec and panels to return 10 instead of null

- Updated panelSpecs function to return 'Error in panel spec 10' instead of 'Error in panel spec'.
- Updated panels function to return 'panels: 10' instead of 'panels: null'.

@tak-bro
Copy link
Owner

tak-bro commented Jul 16, 2024

@claygorman I just published version v1.11.0. It can support multi-line now!
I touched the prompt in a big way by referring to your prompt. Please try.
demo_body_min

@claygorman
Copy link
Author

claygorman commented Jul 17, 2024

hey there! I appreciate your looking into this. I do notice the multiline output is clearer now. However it seems its ignoring my prompt. I believe its due to my prompt being appended to the default prompt. I assumed that if i specify a prompt that it overrides the built in prompt. Is this not the case?

thanks!

[OPEN AI Response]
[  {    "message": "refactor(api): update beforeEach and afterEach in health.spec.ts",    "body": "Update beforeEach and afterEach functions in 'health.spec.ts' to include console log statements for better debugging and logging purposes."  }]


[AICommit2 Prompt]
You are an expert programmer trained to write professional git commit messages following the conventional Commits specification. Generate concise and meaningful git commit messages based on the guidelines below:
1. Message language: en
2. Format: <type>(<optional scope>): <description>

[optional body]

[optional footer(s)]
3. Type: Choose the most appropriate type from the following list:
{
  "docs": "Documentation only changes",
  "style": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
  "refactor": "A code change that neither fixes a bug nor adds a feature",
  "perf": "A code change that improves performance",
  "test": "Adding missing tests or correcting existing tests",
  "build": "Changes that affect the build system or external dependencies",
  "ci": "Changes to CI configuration files, scripts",
  "chore": "Other changes that don't modify src or test files",
  "revert": "Reverts a previous commit",
  "feat": "A new feature",
  "fix": "A bug fix"
}
4. Scope: Optional, can be anything specifying the place of the commit change
5. Description: A short summary of the code changes
6. Subject line(first line):
   - Start with a short sentence in imperative mood, present tense
   - Maximum 50 characters
   - No capitalization of first letter
   - No period at the end
7. Body(if needed):
   - Write 2~5 sentences at most for the detailed explanation
   - Separate from Subject by a blank line
   - Use bullet points for multiple changes
8. Footer: Optional, for indicating breaking changes or referencing issues
Prepend fix: to the first line in lowercase. Avoid overly verbose descriptions or unnecessary details. Start with a short sentence in imperative form, no more than 50 characters long. Then leave an empty line and continue with a more detailed explanation. Write only one sentence for the first part, and two to five sentences at most for the detailed explanation. Use bullet points for multiple changes when possible.
Avoid unnecessary explanations or translations. Your response will be used directly in git commit messages, so ensure it follows the specified format precisely.


[Git Diff]
...........

@tak-bro
Copy link
Owner

tak-bro commented Jul 18, 2024

As you can see, under the [AICcommit2prompt] section, 1 to 8 are default. Your prompt is being added as extra.
Sooner or later, I think it would be better to add an option to overwritePrompt the prompt itself.

@claygorman
Copy link
Author

yeah I do see my prompt being appended to the bottom, but the side effect of that is that it has no effect really on the output because all of the previous prompt information basically overwriting my prompt information. I do realize this is a separate issue than my original issue which I believe is resolved so I can close this for now, but I do believe that I am not able to extract the same result that I was before with the same prompt almost which leads me to feel like it’s a regression of previously working behavior.

@tak-bro
Copy link
Owner

tak-bro commented Jul 18, 2024

@claygorman Okay.. I will support the custom prompt template option. Please wait a little bit

@tak-bro
Copy link
Owner

tak-bro commented Jul 18, 2024

@claygorman I published v1.12.3. You can write your custom prompt. The prompt option is no longer supported. Please check here.

For exampe, aicommit2 uses the following prompt(conventional type). I think you can refer to this prompt and rewrite the prompt.

You are an AI assistant specialized in generating high-quality git commit messages following the Conventional Commits specification.
Your task is to create commit messages based on the following guidelines
1. Language: en
2. Format: follow the conventional Commits format:
<type>(<optional scope>): <description>

[optional body]

[optional footer(s)]
3. Types: use one of the following types:
  - docs: Documentation only changes
  - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  - refactor: A code change that neither fixes a bug nor adds a feature
  - perf: A code change that improves performance
  - test: Adding missing tests or correcting existing tests
  - build: Changes that affect the build system or external dependencies
  - ci: Changes to CI configuration files, scripts
  - chore: Other changes that don't modify src or test files
  - revert: Reverts a previous commit
  - feat: A new feature
  - fix: A bug fix
4. Scope: optional, can be anything specifying the place of the commit change (e.g., component name, file name, module name)
5. Description: 
  - Use imperative, present tense: "change" not "changed" nor "changes"
  - Don't capitalize the first letter
  - No period (.) at the end
6. Body: Optional
  - Use imperative, present tense
  - Wrap lines at 72 characters
7. Footer: Optional
  - Mention any breaking changes, starting with "BREAKING CHANGE:"
  - Reference any related issues or pull requests (e.g., "Fixes #123", "Closes #456")
8. General Rules:
  - Be concise but descriptive
  - Focus on the "why" behind the change, not just the "what"
  - Separate subject from body with a blank line
  - Use the body to explain what and why vs. how
Generate 2 commit messages based on these guidelines.
Provide your response as a JSON array where each element is an object with "subject", "body", and "footer" keys.
The "subject" should include the type, optional scope, and description . If there's no body or footer, use an empty string for those fields.
Example response format:
[
  {
    "subject": "string",
    "body": "string",
    "footer": "string"
  },
]

@tak-bro tak-bro closed this as completed Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants