-
Notifications
You must be signed in to change notification settings - Fork 60.8k
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
in chat list, show model.displayName if it exists + support bytedance's r1 with internet #6220
base: main
Are you sure you want to change the base?
Conversation
@bestsanmao is attempting to deploy a commit to the NextChat Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis pull request modifies the chat interface by conditionally rendering a model's display name in place of its raw identifier. In the component, the displayed text now checks for a provided friendly name before falling back to the original model. Additionally, the chat message type is enhanced by adding an optional property, and a helper function ( Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant C as Chat Component
participant S as Chat Store
participant G as getModelDisplayName
U->>C: Sends chat message
C->>S: Calls onUserInput(message)
S->>G: Retrieves model display name
G-->>S: Returns modelDisplayName (or undefined)
S->>C: Returns botMessage with modelDisplayName property
C->>U: Renders message (using modelDisplayName if available)
Possibly related PRs
Poem
✨ Finishing Touches
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: 0
🧹 Nitpick comments (1)
app/store/chat.ts (1)
155-171
: Consider memoizing the model display name lookup.The function works correctly but could benefit from memoization since the model configurations don't change frequently. This would prevent unnecessary recomputation, especially during chat streaming where
onUpdate
is called frequently.Consider using React's
useMemo
or a memoization library:+import memoize from 'lodash/memoize'; + -function getModelDisplayName( +const getModelDisplayName = memoize(( model: ModelType, providerName: ServiceProvider, -): string | undefined { +): string | undefined => { const configStore = useAppConfig.getState(); const accessStore = useAccessStore.getState(); const allModel = collectModelsWithDefaultModel( configStore.models, [configStore.customModels, accessStore.customModels].join(","), accessStore.defaultModel, ); const matchedModel = allModel.find( (m) => m.name === model && m.provider?.providerName === providerName, ); return matchedModel ? matchedModel.displayName : undefined; -} +});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/components/chat.tsx
(1 hunks)app/store/chat.ts
(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- app/components/chat.tsx
🔇 Additional comments (2)
app/store/chat.ts (2)
63-63
: LGTM! Type definition is well-structured.The optional
modelDisplayName
property is correctly defined and follows TypeScript conventions.
459-462
: LGTM! Display name is correctly set in the bot message.The implementation properly retrieves and sets the model display name using the appropriate configuration values.
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: 0
🧹 Nitpick comments (1)
app/utils.ts (1)
307-309
: Consider refactoring the model prefix checks for better maintainability.While the changes correctly add support for new model types, the growing list of conditions suggests a need for a more maintainable approach.
Consider refactoring to use a configuration array:
+const THINKING_MODEL_PATTERNS = [ + 'dall-e', + 'dalle', + 'o1', + 'o3', + 'deepseek-r', + '-thinking', + 'ep-', + 'bot-' +]; export function getTimeoutMSByModel(model: string) { model = model.toLowerCase(); - if ( - model.startsWith("dall-e") || - model.startsWith("dalle") || - model.startsWith("o1") || - model.startsWith("o3") || - model.includes("deepseek-r") || - model.includes("-thinking") || - model.startsWith("ep-") || - model.startsWith("bot-") - ) + if (THINKING_MODEL_PATTERNS.some(pattern => + pattern.endsWith('-') ? model.startsWith(pattern) : model.includes(pattern) + )) return REQUEST_TIMEOUT_MS_FOR_THINKING; return REQUEST_TIMEOUT_MS; }This approach:
- Makes it easier to maintain the list of special models
- Separates configuration from logic
- Makes the pattern matching logic more explicit
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/client/platforms/bytedance.ts
(1 hunks)app/components/emoji.tsx
(1 hunks)app/constant.ts
(1 hunks)app/utils.ts
(1 hunks)
🔇 Additional comments (4)
app/components/emoji.tsx (1)
85-89
: LGTM! Clean extension of model icon handling.The addition of the "bot-" prefix check alongside existing conditions is well-implemented and maintains consistency with the existing pattern.
app/client/platforms/bytedance.ts (1)
120-120
: LGTM! Proper integration of dynamic chat path.The update correctly uses the new dynamic ChatPath function, enabling proper routing for different model types.
app/constant.ts (1)
219-225
: LGTM! Well-structured dynamic path handling.The implementation of dynamic chat path selection is clean and follows a clear pattern:
- Returns "api/v3/bots/chat/completions" for bot models
- Falls back to "api/v3/chat/completions" for other models
app/utils.ts (1)
299-313
: LGTM! Changes support the model display name feature.The modifications to the timeout handling function appropriately support the new model types, which aligns with the PR's objective of enhancing model display name functionality in the chat list.
bot-开头的应用id申请方式可参考这个链接的方案二
fixed #6177
Summary by CodeRabbit