Skip to content

Add latest models and remove legacy ones#6421

Closed
Davidlasky wants to merge 26 commits intoChatGPTNextWeb:mainfrom
Davidlasky:main
Closed

Add latest models and remove legacy ones#6421
Davidlasky wants to merge 26 commits intoChatGPTNextWeb:mainfrom
Davidlasky:main

Conversation

@Davidlasky
Copy link
Copy Markdown

@Davidlasky Davidlasky commented Apr 2, 2025

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

  1. Defaults o3-mini to high reasoning effort
  2. Add o1 and gemini-2.5-pro-exp to vision models
  3. Remove legacy models of Google, Anthropic and OpenAI, then add their latest models
  4. May have fixed timeout issue for thinking models, more tests needed

📝 补充信息 | Additional Information

Summary by CodeRabbit

  • Chores
    • Updated internal repository settings including .gitignore and Docker environment variables.
    • Upgraded Node.js version and switched package management from Yarn to npm in build and test workflows.
  • Refactor
    • Streamlined AI model configuration handling and processing logic.
    • Adjusted default model parameters for improved response consistency and history management.
    • Filtered available models to include only select providers for better model management.
  • New Features
    • Expanded support for the latest AI models with updated parameters and knowledge cutoff dates.
    • Enhanced recognition for vision-capable models for improved performance.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2025

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

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2025

Walkthrough

This update introduces several modifications across the project. A new ignore entry for a local Dockerfile is added to the VCS configuration. In the client platform files, unused constants and conditions have been removed, and the OpenAI integration now includes an optional property with refined model type checks and token handling. The constants file has been updated with new model identifiers, cutoff dates, and regex patterns. Additionally, the utility function for timeout calculation now evaluates extra conditions, and test cases have been adjusted to reflect updated model names and vision model arrays. Default model configuration parameters have also been tuned. The Dockerfile and CI workflow were updated to use a newer Node.js version and switch from Yarn to npm.

Changes

File(s) Change Summary
.gitignore Added entry Dockerfile.local.
app/client/platforms/anthropic.ts
app/client/platforms/google.ts
Removed unused constant keys in anthropic.ts and deleted the model "-thinking" check in google.ts.
app/client/platforms/openai.ts Added optional property reasoning_effort to RequestPayload, restructured model type checks (isO1, isO3, isO4), adjusted token limits and timeout logic.
app/constant.ts Updated model constants (e.g., SUMMARIZE_MODEL, GEMINI_SUMMARIZE_MODEL), cutoff dates, regex arrays, and model arrays for OpenAI, Google, and Anthropic.
app/utils.ts Modified getTimeoutMSByModel to include extra conditions for "o4" and "pro" models with enhanced logging.
app/store/config.ts Adjusted default model configuration: lowered temperature from 0.5 to 0.2, increased historyMessageCount from 4 to 20, and raised compressMessageLengthThreshold from 1000 to 5000.
test/model-available.test.ts Changed test model name from "gpt-4" to "gpt-4.1".
test/vision-model-checker.test.ts Updated vision model test cases by replacing "gpt-4-vision" with "gpt-4.1", replacing Gemini 1.x and experimental models with "gemini-2.5-pro", and adding "o1" as a vision model.
Dockerfile Updated base image from node:18-alpine to node:23-alpine, switched dependency installation from Yarn to npm, added environment variables ANTHROPIC_API_KEY and VISION_MODELS.
.github/workflows/test.yml Updated Node.js version from 18 to 23, switched package manager from Yarn to npm, adjusted caching and test commands accordingly.
app/utils/hooks.ts Modified useAllModels hook to filter models by allowed providers: OpenAI, Google, and Anthropic.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant OpenAI
    Client->>OpenAI: Send request with model config
    alt Model type is O1, O3, or O4
        OpenAI->>OpenAI: Set reasoning_effort (if O4) and adjust token limits
        OpenAI->>OpenAI: Apply fixed temperature, penalties, and max tokens
    else Other models
        OpenAI->>OpenAI: Use configured parameters and max tokens
    end
    OpenAI->>Client: Return RequestPayload
Loading
sequenceDiagram
    participant Caller as Request Initiator
    participant TimeoutFunc as getTimeoutMSByModel
    Caller->>TimeoutFunc: Call getTimeoutMSByModel(model)
    alt Model includes "-thinking", "o4", or "pro"
        TimeoutFunc->>Caller: Log "thinking model" and return extended timeout
    else
        TimeoutFunc->>Caller: Log "normal model" and return standard timeout
    end
Loading

Possibly related PRs

Suggested labels

planned

Suggested reviewers

  • Dogtiti
  • lloydzhou

Poem

I'm a bunny with code so neat,
Hopping through changes with nimble feet.
Dockerfiles hidden, and old flags gone,
New payloads and tokens happily dawn.
With regex and models, I bound with cheer—
A rabbit's delight in updates so dear!
🐇💻🌟

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

🪧 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.
  • @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
Copy Markdown
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 comments (1)
test/vision-model-checker.test.ts (1)

16-34: 💡 Verification agent

🧩 Analysis chain

Verify complete vision model coverage

This test covers the new models mentioned in the PR (gemini-2.5-pro), but I don't see "o1" which was mentioned in the PR objectives.


🏁 Script executed:

#!/bin/bash
# Check for the presence of "o1" in VISION_MODEL_REGEXES
rg -A 1 "VISION_MODEL_REGEXES" app/constant.ts

Length of output: 175


Action: Update the regex or test suite to include the 'o1' model

The current VISION_MODEL_REGEXES (in app/constant.ts) only includes the /vision/ pattern and does not cover the "o1" model specified in the PR objectives. Please adjust the regex definitions or update the test suite accordingly to ensure complete vision model coverage.

  • Location: app/constant.ts (where VISION_MODEL_REGEXES is defined)
  • Required Update: Include a regex that matches "o1" if that model is expected to be recognized.
🧹 Nitpick comments (1)
app/utils.ts (1)

307-318: Consider more specific model matching for timeouts

While adding model.includes("pro") to the timeout logic will work for the new models mentioned in the PR, this pattern might be too broad and could inadvertently apply longer timeouts to models that don't need them.

Consider using a more specific condition or maintaining a list of models that specifically need the longer timeout:

- model.includes("-thinking") ||
- model.includes("pro")
+ model.includes("-thinking") || 
+ (model.includes("pro") && (
+   model.includes("gemini-2.5-pro") || 
+   model.includes("gemini-1.5-pro")
+ ))

The enhanced logging is helpful for debugging timeout issues.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 48469bd and f2a5af7.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (8)
  • .gitignore (1 hunks)
  • app/client/platforms/anthropic.ts (0 hunks)
  • app/client/platforms/google.ts (0 hunks)
  • app/client/platforms/openai.ts (4 hunks)
  • app/constant.ts (3 hunks)
  • app/utils.ts (1 hunks)
  • test/model-available.test.ts (1 hunks)
  • test/vision-model-checker.test.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • app/client/platforms/anthropic.ts
  • app/client/platforms/google.ts
🧰 Additional context used
🧬 Code Definitions (1)
app/client/platforms/openai.ts (1)
app/utils.ts (1)
  • getTimeoutMSByModel (299-320)
🔇 Additional comments (13)
.gitignore (1)

52-52: LGTM: Adding local Dockerfile to gitignore

Adding Dockerfile.local to .gitignore is a good practice to prevent local Docker configurations from being committed to the repository.

test/model-available.test.ts (1)

6-6: Model name update looks good

Updating the test to use "gpt-4o" instead of "gpt-4" aligns with the PR objective of removing legacy models and adding new ones.

test/vision-model-checker.test.ts (1)

18-18: Vision model list update aligns with PR objectives

Updating the vision models test list to include "gpt-4o" instead of "gpt-4-vision" and adding "gemini-2.5-pro" aligns with the PR objective of updating to newer models.

Also applies to: 22-22

app/client/platforms/openai.ts (5)

70-71: Added new property for O3 models' reasoning capability

The addition of reasoning_effort optional parameter allows controlling how much reasoning effort the O3 models will apply, which is a key feature of these newer models.


201-203: Clear model type identification with separated boolean variables

Good refactoring that improves readability by explicitly separating O1 and O3 model checks, then combining them into a single variable for shared behaviors.


247-250: Setting high reasoning effort for O3 models by default

This change implements the PR objective to adjust the default setting for o3-mini to use high reasoning effort, which should improve the quality of responses.


254-258: Model-specific token handling logic

The improved conditional logic handles token parameters differently based on model type:

  • For O1: Uses max_completion_tokens as per O1 API requirements
  • For other vision models: Sets max_tokens with a minimum threshold of 4000

This change ensures each model type receives appropriate token limits.


301-304: Enhanced timeout calculation for different model types

The timeout logic now uses getTimeoutMSByModel function which applies different timeout values based on model type. This likely addresses the timeout issue with thinking models mentioned in the PR objectives.

app/constant.ts (5)

412-412: Updated GEMINI_SUMMARIZE_MODEL to newer version

Changed from "gemini-pro" to "gemini-2.0-flash", which aligns with the PR objective to remove legacy models and add latest versions.


416-422: Updated knowledge cutoff dates for latest models

The changes include:

  • Updated default cutoff from "2023-10" (more recent than previous)
  • Added new entries for Gemini and Claude models with appropriate cutoff dates
  • These updates ensure the models reference the correct knowledge timeframes

This aligns with adding new models from Google and Anthropic as mentioned in the PR objectives.


448-448: Added vision capability detection for new models

Added regex patterns to identify "gemini-2.5-pro" and "o1" as vision models, which supports the PR objective of adding new vision models (o1 and gemini-2.5-pro-exp).

Also applies to: 456-456


470-470: Added new OpenAI models

Added "o1" and "gpt-4.5-preview" to the OpenAI models array, which aligns with the PR objective to add new models and specifically mentions o1 as one of the new vision models.

Also applies to: 472-472


480-481: Added new Google models

Added "gemini-2.0-flash-lite" and "gemini-2.5-pro-exp-03-25" to the Google models array. The latter is specifically mentioned in the PR objectives as one of the new vision models being added.

Copy link
Copy Markdown
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: 2

🧹 Nitpick comments (3)
Dockerfile (1)

9-13: Lock‑file mismatch and registry pinning

  1. COPY package.json package-lock.json ./ – the project previously used Yarn; ensure package-lock.json is committed and up‑to‑date, or the build will ignore your intended dependency tree.
  2. Using a mirror with npm config set registry hard‑codes every install to npmmirror.com. Consider shipping an .npmrc instead so local devs inherit the same config, or gate this behind ARG NPM_REGISTRY=.
  3. Add --prefer-offline --no-audit --fund=false flags to speed up CI and silence audit noise.

Example improvement:

-RUN npm config set registry 'https://registry.npmmirror.com/'
-RUN npm install
+ARG NPM_REGISTRY=https://registry.npmmirror.com/
+RUN npm config set registry "$NPM_REGISTRY" \
+  && npm ci --prefer-offline --no-audit --fund=false
app/utils/hooks.ts (1)

6-11: Prefer a Set for O(1) look‑ups and easier extension

Since allowedProviders is used only for membership tests, converting it to a Set avoids the linear cost of Array.prototype.includes inside every filter operation.

-const allowedProviders = [
-  ServiceProvider.OpenAI,
-  ServiceProvider.Google,
-  ServiceProvider.Anthropic,
-];
+const allowedProviders = new Set<ServiceProvider>([
+  ServiceProvider.OpenAI,
+  ServiceProvider.Google,
+  ServiceProvider.Anthropic,
+]);

Remember to change includeshas below.

app/constant.ts (1)

457-483: Minor naming inconsistencies (alibabaModes, moonshotModes, …)

The variable suffix alternates between Models and Modes, which can confuse future maintainers. Consider renaming for consistency:

-const alibabaModes = ["qwen-vl-max"];
+const alibabaModels = ["qwen-vl-max"];

Repeat for moonshotModes, xAIModes, etc.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ac7b720 and d2e484f.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • Dockerfile (2 hunks)
  • app/client/platforms/openai.ts (5 hunks)
  • app/constant.ts (13 hunks)
  • app/utils.ts (1 hunks)
  • app/utils/hooks.ts (1 hunks)
  • test/vision-model-checker.test.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/vision-model-checker.test.ts
  • app/utils.ts
  • app/client/platforms/openai.ts
🔇 Additional comments (5)
Dockerfile (2)

22-22: npm run build assumes lifecycle scripts are already migrated

Double‑check that package.json has a "build" script using npm syntax and that no Yarn‑specific commands remain (workspaces, yarn build --filter etc.).
Otherwise this stage will fail at runtime.


32-33: ENV variables added but not documented / referenced in code

ANTHROPIC_API_KEY and VISION_MODELS are declared, yet no default values or documentation are provided.
• If they are required at runtime, the container will silently start with empty strings, leading to confusing 401s.
• Add them to README.md and consider ARG + ENV combo with sensible defaults (<unset>).

[ suggest_nitpick]

app/utils/hooks.ts (1)

24-31: Filtering excludes Azure and other user‑added providers – is that intentional?

Users who configure their own Azure‑OpenAI or Moonshot endpoints via the UI will now see their custom models disappear from the picker because provider.providerName won’t match the hard‑coded list.
If the goal is merely to hide built‑in unsupported models, consider:

if (model.provider?.providerType === "azure" && model.available) return true

Or expose a toggle in settings.

app/constant.ts (2)

411-413: Summarise model constants updated – check downstream defaults

Changing SUMMARIZE_MODEL to "gpt-4.1-mini" and GEMINI_SUMMARIZE_MODEL to "gemini-2.0-flash" affects every place where the summariser runs automatically (message export, auto‑condense etc.).
Verify token pricing and availability limits for these newer models; otherwise costs could spike or requests may 404 if the tenant lacks access.


502-505: All Azure‑flavoured OpenAI models set to available: false

If users rely on Azure deployments, the UI may hide these models entirely.
Confirm that the “unavailable” flag is deliberate; otherwise revert to true or make availability user‑configurable.

Comment thread Dockerfile
@@ -1,29 +1,25 @@
FROM node:18-alpine AS base
FROM node:23-alpine AS base
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Node 23‑alpine may not yet be an LTS image – verify runtime compatibility and availability

Jumping from node:18-alpine (current LTS) to node:23-alpine brings bleeding‑edge V8 semantics and potential ABI changes.
• Some native add‑ons compiled during npm install (e.g. sharp, bcrypt) may break.
• Docker Hub does not currently publish an official 23-alpine tag; the build will 404.

Unless you explicitly need Node 23 features, stick to the latest LTS (node:20‑alpine) or test the new tag’s existence in CI before merging.

Comment thread app/constant.ts
Comment on lines 444 to 453
export const VISION_MODEL_REGEXES = [
/vision/,
/gpt-4o/,
/gpt-4/,
/claude-3/,
/gemini-1\.5/,
/gemini-exp/,
/gemini-2\.0/,
/learnlm/,
/qwen-vl/,
/qwen2-vl/,
/gpt-4-turbo(?!.*preview)/, // Matches "gpt-4-turbo" but not "gpt-4-turbo-preview"
/gemini/,
/^dall-e-3$/, // Matches exactly "dall-e-3"
/glm-4v/,
/vl/i,
/o1/,
/o3/,
/o4/,
];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

/gpt-4/ regex is overly broad – non‑vision GPT‑4 models will be mis‑classified

Replacing the old /gpt-4o/ with /gpt-4/ means text‑only models like "gpt-4.1-mini" now satisfy VISION_MODEL_REGEXES, triggering vision‑specific UI flows and higher timeouts.

Recommend refining the pattern:

-/gpt-4/,
+/gpt-4(?:o|v?ision)/,   // gpt-4o, gpt-4-vision
+/\bgpt-4\.1\b/,         // explicit 4.1 vision variant if needed

or enumerate explicit model names similar to the new o1|o3|o4 additions.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const VISION_MODEL_REGEXES = [
/vision/,
/gpt-4o/,
/gpt-4/,
/claude-3/,
/gemini-1\.5/,
/gemini-exp/,
/gemini-2\.0/,
/learnlm/,
/qwen-vl/,
/qwen2-vl/,
/gpt-4-turbo(?!.*preview)/, // Matches "gpt-4-turbo" but not "gpt-4-turbo-preview"
/gemini/,
/^dall-e-3$/, // Matches exactly "dall-e-3"
/glm-4v/,
/vl/i,
/o1/,
/o3/,
/o4/,
];
export const VISION_MODEL_REGEXES = [
/vision/,
- /gpt-4/,
+ /gpt-4(?:o|v?ision)/, // gpt-4o, gpt-4-vision
+ /\bgpt-4\.1\b/, // explicit 4.1 vision variant if needed
/claude-3/,
/gemini/,
/^dall-e-3$/, // Matches exactly "dall-e-3"
/o1/,
/o3/,
/o4/,
];

Copy link
Copy Markdown
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)
.github/workflows/test.yml (1)

31-31: Validate cache key for npm dependencies
Switching the cache key to target package-lock.json is appropriate for npm. Ensure that the pattern '**/package-lock.json' correctly matches your lockfile’s path.

You could simplify by leveraging only the built‑in cache from setup-node (removing this manual cache) to reduce complexity.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa2c68 and e4264d3.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
🔇 Additional comments (3)
.github/workflows/test.yml (3)

24-25: Review Node.js version and caching strategy
You've updated node-version to 23 and set cache: 'npm'.

  • Confirm that Node.js 23 is officially supported and stable for your CI environment; you may prefer the latest LTS (e.g., 20.x) for production use.
  • Verify that the built-in npm caching in setup-node doesn’t conflict with the separate actions/cache step below.

36-36: Switch install command to npm
Replacing yarn install with npm install aligns with the package manager change. Please verify that no residual Yarn commands or lockfiles remain in the repository.


39-39: Update test command for npm
Changing yarn test:ci to npm run test:ci is correct; ensure that a test:ci script is defined in your package.json and that it runs as expected under the new Node.js version.

@Davidlasky
Copy link
Copy Markdown
Author

similar feature already merged and deployed.

@Davidlasky Davidlasky closed this Apr 18, 2025
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.

2 participants