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

fix o1系列模型超时时间改为4分钟, #5658

Merged
merged 2 commits into from
Oct 14, 2024

Conversation

ccq18
Copy link
Contributor

@ccq18 ccq18 commented Oct 14, 2024

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

由于o1系列模型响应时间经常超过1分钟,因此修改默认超时时间为3分钟,减少响应超时的情况

📝 补充信息 | Additional Information

Summary by CodeRabbit

  • New Features
    • Increased request timeout duration from 60 seconds to 180 seconds, allowing for longer wait times before a request is deemed failed.
    • Enhanced error handling and message formatting for improved readability in response processing.
    • Improved payload construction for different model types and configurations, enhancing overall functionality.

Copy link

vercel bot commented Oct 14, 2024

@ccq18 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 Oct 14, 2024

Walkthrough

The pull request modifies the REQUEST_TIMEOUT_MS constant in the app/constant.ts file, changing its value from 60 seconds (60000 milliseconds) to 180 seconds (180000 milliseconds). This adjustment increases the duration for which requests can wait before being deemed failed. Additionally, the ChatGPTApi class in the app/client/platforms/openai.ts file has been updated to utilize this new timeout value, particularly for DALL-E 3 and O1 model requests.

Changes

File Change Summary
app/constant.ts Updated REQUEST_TIMEOUT_MS from 60000 to 180000 ms.
app/client/platforms/openai.ts Adjusted timeout for DALL-E 3 and O1 models in chat method to REQUEST_TIMEOUT_MS * 4. Enhanced extractMessage method for better error handling and response processing.

Possibly related PRs

  • feat: add o1 model #5416: This PR modifies the ChatGPTApi class in app/client/platforms/openai.ts, which is also updated in the main PR to utilize the new REQUEST_TIMEOUT_MS constant, indicating a direct relationship in handling request timeouts for the "o1" model.

Suggested reviewers

  • lloydzhou
  • Dogtiti

Poem

🐇 In the meadow where time flows slow,
A timeout change, a gentle glow.
From sixty to one-eighty, we wait with glee,
Requests now linger, as happy as can be!
Hops of joy in the code we write,
Longer waits make our dreams take flight! 🌼


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 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.

@lloydzhou
Copy link
Member

这里不建议直接改全局的超时时间。建议针对o1模型做更改

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It is not recommended to directly change the global timeout here. It is recommended to make changes to the o1 model

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b016771 and 12e7caa.

📒 Files selected for processing (1)
  • app/constant.ts (1 hunks)
🧰 Additional context used

app/constant.ts Outdated
@@ -95,7 +95,7 @@ export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id;

export const STORAGE_KEY = "chatgpt-next-web";

export const REQUEST_TIMEOUT_MS = 60000;
export const REQUEST_TIMEOUT_MS = 180000;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Action Required: Review Global Impact of Timeout Change

The REQUEST_TIMEOUT_MS constant is used across multiple modules in the codebase. Changing it globally to 180000ms will affect all components that rely on this timeout value.

Recommendations:

  1. Assess Scope: Determine if the increased timeout should apply universally or only to specific models (e.g., o1 series).
  2. Refactor if Necessary:
    • If the timeout increase is intended only for certain models, consider creating model-specific timeout constants.
    • Example:
      export const DEFAULT_REQUEST_TIMEOUT_MS = 60000;
      export const O1_REQUEST_TIMEOUT_MS = 180000;
  3. Update Usages: Ensure that each usage of the timeout constant references the appropriate value based on the context.

Implementing these changes will help prevent unintended side effects and maintain optimal performance across different parts of the application.

🔗 Analysis chain

Approved: Timeout increased to 3 minutes as per PR objective.

The change from 60000ms to 180000ms (3 minutes) aligns with the PR objective to address timeout issues for o1 series models. This modification should help reduce the occurrence of response timeouts.

However, consider the following suggestions:

  1. Verify if this timeout should apply universally or if it should be model-specific.
  2. Add a comment explaining the rationale behind the 3-minute timeout, e.g.:
    // Increased to 3 minutes to accommodate longer response times of o1 series models
    export const REQUEST_TIMEOUT_MS = 180000;

To ensure this change doesn't affect other parts of the codebase unintentionally, please run the following command:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of REQUEST_TIMEOUT_MS
rg "REQUEST_TIMEOUT_MS" --type typescript

Length of output: 76


Script:

#!/bin/bash
# Search for other usages of REQUEST_TIMEOUT_MS in TypeScript files
rg "REQUEST_TIMEOUT_MS" -g "*.ts" -g "*.tsx"

Length of output: 1469

Copy link
Contributor

Your build has completed!

Preview deployment

@ccq18 ccq18 changed the title fix 默认超时时间改为3分钟, fix 默认超时时间改为4分钟, Oct 14, 2024
@ccq18
Copy link
Contributor Author

ccq18 commented Oct 14, 2024

这里不直接建议全局改变超时时间。建议针对o1模型做更改

已修改,将o1系列目前默认的2分钟改为4分钟

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It is not directly recommended to change the timeout globally here. It is recommended to make changes to the o1 model

Modified, changing the current default 2 minutes of the o1 series to 4 minutes

@ccq18 ccq18 changed the title fix 默认超时时间改为4分钟, fix o1系列模型超时时间改为4分钟, Oct 14, 2024
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

🧹 Outside diff range and nitpick comments (1)
app/client/platforms/openai.ts (1)

355-355: Update comment to reflect increased timeout for O1 models

The inline comment mentions that DALL-E 3 is slow, but the timeout is also increased for O1 models. Consider updating the comment to reflect that both DALL-E 3 and O1 models may have longer response times.

Apply this diff to update the comment:

-              isDalle3 || isO1 ? REQUEST_TIMEOUT_MS * 4 : REQUEST_TIMEOUT_MS, // dalle3 using b64_json is slow.
+              isDalle3 || isO1 ? REQUEST_TIMEOUT_MS * 4 : REQUEST_TIMEOUT_MS, // DALL-E 3 and O1 models may have longer response times.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 12e7caa and 592f620.

📒 Files selected for processing (1)
  • app/client/platforms/openai.ts (1 hunks)
🧰 Additional context used

@lloydzhou lloydzhou merged commit c25903b into ChatGPTNextWeb:main Oct 14, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants