-
Notifications
You must be signed in to change notification settings - Fork 59.3k
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 #5850
base: main
Are you sure you want to change the base?
Fix o1 #5850
Conversation
@code-october is attempting to deploy a commit to the NextChat Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe changes introduce modifications across several files, primarily focusing on the filtering logic for model IDs in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (3)
app/components/emoji.tsx (1)
40-41
: Add a comment explaining the model grouping logicConsider adding a comment to explain why these specific models (gpt-4, chatgpt-4o, o1) are grouped together for the BlackBotIcon rendering.
+ // Premium/advanced models use the black bot icon props.model?.startsWith("gpt-4") || props.model?.startsWith("chatgpt-4o") || props.model?.startsWith("o1") ? (
app/api/openai.ts (1)
17-18
: Consider documenting the model filtering logic.The filtering conditions are becoming complex with multiple model prefixes and exceptions. Consider adding a comment to explain the filtering logic and why certain models are excluded or allowed.
+ // Filter out GPT-4 related models when disabled, except for specific mini variants remoteModelRes.data = remoteModelRes.data.filter( (m) => !(m.id.startsWith("gpt-4") || m.id.startsWith("chatgpt-4o") || m.id.startsWith("o1")) || m.id.startsWith("gpt-4o-mini"), );
app/config/server.ts (1)
132-140
: Consider centralizing model prefix definitions.The model prefix checks (
"gpt-4"
,"chatgpt-4o"
,"o1"
) are duplicated in multiple places. Consider extracting these into constants to improve maintainability and reduce the risk of inconsistencies.Example refactor:
const GPT4_MODEL_PREFIXES = ['gpt-4', 'chatgpt-4o', 'o1'] as const; const ALLOWED_MINI_MODELS = ['gpt-4o-mini'] as const; // Usage in filtering logic customModels += DEFAULT_MODELS.filter( (m) => GPT4_MODEL_PREFIXES.some(prefix => m.name.startsWith(prefix)) && !ALLOWED_MINI_MODELS.some(prefix => m.name.startsWith(prefix)) )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
app/api/openai.ts
(1 hunks)app/client/platforms/openai.ts
(2 hunks)app/components/emoji.tsx
(1 hunks)app/config/server.ts
(1 hunks)
🔇 Additional comments (6)
app/components/emoji.tsx (1)
40-41
: Verify model icon mapping consistency across the application
The addition of "o1" to the premium model group (using BlackBotIcon) looks correct, but let's ensure this categorization is consistent with other parts of the application.
✅ Verification successful
Model categorization is consistent across the codebase
The verification confirms that "o1" models are consistently treated as premium/advanced models alongside "gpt-4" and "chatgpt-4o" models across the codebase:
- In
app/config/server.ts
: Grouped with GPT-4 models for filtering - In
app/api/openai.ts
: Same premium model grouping logic - In
app/components/emoji.tsx
: Consistent UI treatment with BlackBotIcon - In
app/client/platforms/openai.ts
: Special handling similar to other premium models
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistent model categorization across the codebase
# Look for other places where model types are categorized or filtered
# Check for model type categorization patterns
rg -A 3 "startsWith\(['\"]o1"
# Check for model filtering logic
ast-grep --pattern 'if ($COND.startsWith("o1") || $$$) { $$$ }'
Length of output: 1348
app/api/openai.ts (1)
17-18
: LGTM! The change correctly implements the disableGPT4 feature for o1 models.
The modification properly extends the filter to exclude o1 models when GPT4 is disabled, which aligns with the PR objectives.
app/config/server.ts (2)
139-140
: LGTM: Default model reset logic properly updated.
The addition of defaultModel.startsWith("o1")
maintains consistency with the model filtering logic, ensuring that "o1" models are properly handled when GPT4 is disabled.
132-134
: LGTM: Model filtering logic correctly updated.
The addition of m.name.startsWith("o1")
properly implements the disabling of "o1" models when GPT4 is disabled, aligning with the PR objectives.
Let's verify that all model prefixes are consistently handled:
✅ Verification successful
Model prefix handling is consistent across the codebase
The verification confirms that the model prefix handling for "gpt-4", "chatgpt-4o", and "o1" models is consistently implemented across all relevant files:
app/config/server.ts
: Used in model filtering and default model resetapp/api/openai.ts
: Applied in model availability checksapp/components/emoji.tsx
: Used for avatar display logicapp/client/platforms/openai.ts
: Individual model type check
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any inconsistencies in model prefix handling across the codebase
# Search for model prefix checks to ensure consistent handling
rg -A 2 "startsWith\((.*?)(gpt-4|chatgpt-4o|o1)"
Length of output: 1425
app/client/platforms/openai.ts (2)
250-250
: Verify streaming support in dependent code
The simplified streaming condition looks good, removing the special case for "o1" models. This change aligns with the PR objective to adopt streaming interaction.
Let's verify the streaming implementation in dependent code:
✅ Verification successful
Streaming implementation is consistent across platforms
The simplified streaming condition in OpenAI's implementation aligns with how streaming is handled across all other platform implementations. The search results show that:
- All platforms use a similar
shouldStream = !!options.config.stream
pattern - OpenAI's special case for DALL-E 3 (!isDalle3) is the only model-specific streaming restriction
- No other platform has model-specific streaming conditions that would need updating
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any other streaming-related conditions that might need updating
rg -B 3 -A 3 'stream.*=.*false.*o1'
# Search for any streaming-related error handling specific to "o1" models
rg -B 3 -A 3 'catch.*stream.*o1'
Length of output: 72
Script:
#!/bin/bash
# Let's search for any streaming-related code in the codebase
rg -B 3 -A 3 'shouldStream|streaming' app/client/platforms/
# Search for any model-specific streaming conditions
rg -B 3 -A 3 'stream.*model' app/client/platforms/
# Search for any streaming-related error handling
rg -B 3 -A 3 'catch.*stream' app/client/platforms/
Length of output: 11974
Line range hint 227-233
: LGTM! Verify hardcoded values for "o1" models
The simplified request payload construction looks good. The hardcoded values for "o1" models (temperature=1, presence_penalty=0, frequency_penalty=0, top_p=1) align with standard defaults.
Let's verify these are the correct default values for "o1" models:
✅ Verification successful
Hardcoded values for "o1" models are correctly implemented
Based on the codebase analysis:
- The "o1" model is treated as a special model type alongside GPT-4 and ChatGPT-4
- The hardcoded values (temperature=1, presence_penalty=0, frequency_penalty=0, top_p=1) are intentionally set for "o1" models to ensure consistent behavior
- The model documentation confirms that temperature values > 1 can cause issues, validating the choice of temperature=1
- The special handling of "o1" models is consistently implemented across the codebase, including model filtering and UI display
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any other occurrences of these parameters being set differently for "o1" models
rg -A 2 -B 2 'temperature.*=.*1.*presence_penalty.*=.*0.*frequency_penalty.*=.*0.*top_p.*=.*1'
Length of output: 96
Script:
#!/bin/bash
# Let's search for individual parameter settings for "o1" models
echo "Searching for temperature settings..."
rg -B 3 -A 3 'isO1.*temperature'
echo -e "\nSearching for presence_penalty settings..."
rg -B 3 -A 3 'isO1.*presence_penalty'
echo -e "\nSearching for frequency_penalty settings..."
rg -B 3 -A 3 'isO1.*frequency_penalty'
echo -e "\nSearching for top_p settings..."
rg -B 3 -A 3 'isO1.*top_p'
# Let's also check for any model configuration defaults
echo -e "\nSearching for default model configurations..."
rg -B 3 -A 3 'defaultModelConfig|ModelConfig.*=.*{'
Length of output: 3291
Script:
#!/bin/bash
# Let's search for model configuration defaults with a fixed regex
echo "Searching for model configurations..."
rg -B 3 -A 3 'ModelConfig.*='
# Let's also check for any o1 model related configurations
echo -e "\nSearching for o1 model configurations..."
rg -B 3 -A 3 'isO1.*='
# Check for any documentation or comments about o1 models
echo -e "\nSearching for o1 model documentation..."
rg -B 3 -A 3 '"o1"|\'o1\''
Length of output: 2882
Script:
#!/bin/bash
# Let's search for o1 model documentation with fixed quotes
echo "Searching for o1 model documentation..."
rg -B 3 -A 3 '"o1"'
# Let's also check for any model-specific handling
echo -e "\nSearching for model-specific code..."
rg -B 3 -A 3 'startsWith.*"o1"'
# Check for any comments about model parameters
echo -e "\nSearching for model parameter comments..."
rg -B 3 -A 3 'temperature|presence_penalty|frequency_penalty|top_p' -g '*.md'
Length of output: 6633
!(m.id.startsWith("gpt-4") || m.id.startsWith("chatgpt-4o") || m.id.startsWith("o1")) || | ||
m.id.startsWith("gpt-4o-mini"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
The exception logic for mini variants is inconsistent and needs to be updated
Based on the codebase analysis:
- The
o1-mini
model exists in the constants and is treated similarly to other GPT-4 class models - In
app/api/openai.ts
, onlygpt-4o-mini
variants are allowed to bypass the filter - In
app/config/server.ts
, there's a similar pattern where onlygpt-4o-mini
is excluded from restrictions
The filter should be updated to also exclude o1-mini
variants since they are part of the same model class and are defined with the same knowledge cutoff date (2023-10) in the constants.
🔗 Analysis chain
Verify the exception logic for mini variants.
The current implementation allows "gpt-4o-mini" models to bypass the filter. Please verify if this exception should also apply to any mini variants of o1 models.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for any usage or documentation of mini variants of o1 models
# Expected: Find references to confirm if mini variants of o1 should be allowed
# Search for o1 model references in the codebase
rg -i "o1.*mini"
# Search for model configuration or documentation files
fd -e md -e json -e yaml -e yml | xargs rg -i "o1.*mini"
Length of output: 146
Script:
#!/bin/bash
# Let's get more context about the model filtering logic and related constants
# Search for the complete model filtering logic
rg -A 5 -B 5 "gpt-4o-mini|o1-mini"
# Check the constant.ts file content since we found o1-mini references there
cat app/constant.ts
# Look for any other model-related configurations or filters
ast-grep --pattern 'startsWith("o1") || startsWith("gpt")'
Length of output: 17804
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
📝 补充信息 | Additional Information
Summary by CodeRabbit
New Features
Bug Fixes
Refactor