Skip to content

Add support of presence_penalty and frequency_penalty parameter #773

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PeterDaveHello
Copy link
Member

The frequency and presence penalties help reduce the likelihood of repetitive token sequences, allowing for more varied and contextually appropriate outputs.

By implementing these options, we can gain finer control over the AI's behavior, leading to improved content generation.

Reference docs:

@PeterDaveHello
Copy link
Member Author

Screenshot:

screenshot

@PeterDaveHello
Copy link
Member Author

@josStorer please let me know what do you think ;)

@josStorer
Copy link
Member

josStorer commented Jan 31, 2025

Different APIs have varying default values for presence/frequency penalty. Typically, the default values used by APIs are sufficient for common application scenarios. Setting a global default value for these two parameters might be helpful for specific user scenarios, but it could also negatively impact the performance of certain APIs.

Of course, there's nothing wrong with this PR itself. The default values for these two parameters in the OpenAI API are both 0, but this could affect users who utilize custom APIs. In contrast, the temperature parameter is more commonly used, its impact is more predictable, and it is sufficient for most users, which can also reduce the complexity of the software itself.

I believe that the target users of ChatGPTBox will hardly ever need to modify these two parameters.

If we do decide to provide this feature, it would be best to add a CheckBox component to make it optional, or even better, allow each API to configure these parameters individually. However, due to my personal laziness, and considering the increase in software complexity, along with the fact that I don't think this feature is very important, I have been procrastinating on implementing it. 🤣

@PeterDaveHello
Copy link
Member Author

You're right, I can see how to add a CheckBox component for them. Hopefully, with some help from AI assistants, it won’t take much time. 😆

@PeterDaveHello PeterDaveHello marked this pull request as draft January 31, 2025 11:00
@PeterDaveHello PeterDaveHello requested a review from Copilot May 31, 2025 20:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the presence_penalty and frequency_penalty parameters to various OpenAI API integrations and updates the UI to allow users to adjust these settings while localizing the associated labels.

  • Added penalty parameters in the OpenAI, Azure OpenAI, and ChatGPT API calls.
  • Updated the configuration defaults and UI controls (including sliders) for these parameters.
  • Enhanced localization files for multiple languages to include the new penalty labels.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/services/apis/openai-api.mjs Added penalty parameters to the GPT API calls
src/services/apis/azure-openai-api.mjs Added penalty parameters to the Azure OpenAI API
src/popup/sections/AdvancedPart.jsx Introduced UI sliders for adjusting penalty values
src/config/index.mjs Updated default configuration with penalty values
src/_locales/*/main.json Updated localization files to include penalty labels

@PeterDaveHello
Copy link
Member Author

/review

Copy link

qodo-merge-pro bot commented Jun 2, 2025

Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@PeterDaveHello
Copy link
Member Author

/improve

Copy link

qodo-merge-pro bot commented Jun 2, 2025

Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

PR Code Suggestions ✨

No code suggestions found for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants