Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: remove inappropriate parameters for o3 from the request #6131

Closed
wants to merge 2 commits into from

Conversation

MonadMonAmi
Copy link
Contributor

@MonadMonAmi MonadMonAmi commented Feb 2, 2025

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

📝 补充信息 | Additional Information

Summary by CodeRabbit

  • New Features
    • Enhanced chat functionality by extending support to an additional model type.
    • Improved parameter handling (e.g., temperature, penalties, token limits) to deliver more consistent chat responses.
    • Updated message processing logic to accommodate new model types.

Copy link

vercel bot commented Feb 2, 2025

@MonadMonAmi is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Walkthrough

The changes expand the ChatGPTApi class functionality by incorporating a new boolean variable isO3, which checks if the model starts with "o3". This variable is used in conditional statements to update the behavior of the chat method. The logic for filtering out messages with the "system" role and setting values in the requestPayload (such as temperature, presence penalty, frequency penalty, top_p, and max_completion_tokens) has been modified to apply uniformly for both isO1 and isO3 model types.

Changes

File Change Summary
app/.../openai.ts Modified ChatGPTApi class: Added isO3 variable to detect models starting with "o3"; added isO1Exact variable for exact "o1" matching; updated message filtering to skip "system" messages and adjusted requestPayload parameters (temperature, presence penalty, frequency penalty, top_p, max_completion_tokens) to support both model types.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant API as ChatGPTApi
    participant SRV as OpenAI Server

    C->>API: chat(options)
    API->>API: Check if model starts with "o1" or "o3" (isO1/isO3)
    API->>API: Filter out "system" messages if isO1 or isO3
    API->>API: Set requestPayload parameters (temperature, penalties, top_p, max_completion_tokens)
    API->>SRV: Send requestPayload
    SRV-->>API: Return response
    API-->>C: Deliver chat response
Loading

Poem

In my burrow of code, a new hop I see,
isO3 springs to life with a gleeful decree.
Filtering out systems, payloads now refined,
Logic and parameters happily aligned.
Carrots of change and bytes so sweet,
A bunny's code celebration, a joyful feat!
🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/platforms/openai.ts (1)

222-223: Update comment to include O3 limitations.

The code comment at line 226 only mentions O1 limitations, but the code implies O3 has similar limitations. Consider updating the comment to include O3.

-// O1 not support image, tools (plugin in ChatGPTNextWeb) and system, stream, logprobs, temperature, top_p, n, presence_penalty, frequency_penalty yet.
+// O1 and O3 do not support image, tools (plugin in ChatGPTNextWeb) and system, stream, logprobs, temperature, top_p, n, presence_penalty, frequency_penalty yet.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 566406f and 9117a10.

📒 Files selected for processing (1)
  • app/client/platforms/openai.ts (2 hunks)
🔇 Additional comments (3)
app/client/platforms/openai.ts (3)

198-200: LGTM! Clear and consistent model type checks.

The new model type checks follow existing naming conventions and are implemented logically.


229-234: Verify streaming support for O3.

The code allows streaming for O3 but disables it for O1. Please verify if this is the intended behavior as both models seem to share other limitations.

#!/bin/bash
# Description: Search for any documentation or tests that confirm O3's streaming capability
rg -A 5 "o3.*stream|stream.*o3"

239-242: Update comment and verify token control for O3.

The comment only mentions O1's token control mechanism, but the code applies it to O3 as well. Consider:

  1. Updating the comment to include O3
  2. Verifying if O3 uses the same token control mechanism
-// O1 使用 max_completion_tokens 控制token数 (https://platform.openai.com/docs/guides/reasoning#controlling-costs)
+// O1 and O3 use max_completion_tokens to control token count (https://platform.openai.com/docs/guides/reasoning#controlling-costs)
#!/bin/bash
# Description: Search for documentation about O3's token control mechanism
rg -A 5 "o3.*token|token.*o3|max_completion_tokens.*o3"

@Leizhenpeng
Copy link
Member

fix #6132

@Leizhenpeng Leizhenpeng closed this Feb 4, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants