/* * Copyright 2025 coze-dev Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { lazy, Suspense } from 'react'; import classNames from 'classnames'; import { Tag, Highlight, Typography, Avatar, type TagProps, } from '@coze-arch/coze-design'; import { Popover } from '@coze-arch/bot-semi'; import { IconInfo } from '@coze-arch/bot-icons'; import { useFlags } from '@coze-arch/bot-flags'; import { type ModelDescGroup } from '@coze-arch/bot-api/developer_api'; const LazyModelDescription = lazy(async () => { const { ModelDescription } = await import('./model-description'); return { default: ModelDescription, }; }); const ModelDescription = (props: { descriptionGroupList: ModelDescGroup[]; }) => ( ); export interface OptionItemTag { label: string; color?: TagProps['color']; } export interface OptionItemProps { tokenLimit: number | undefined; descriptionGroupList: ModelDescGroup[] | undefined; avatar: string | undefined; name: string | undefined; searchWords?: string[]; endPointName?: string; // 接入点名称(专业版有) showEndPointName?: boolean; className?: string; /** * @deprecated * 原先只会有「限额」标签,M-5395720900 后会有大量新标签,避免兼容问题产品同意先简单隐藏掉标签展示 */ tags?: OptionItemTag[]; } export const ModelOptionItem: React.FC = ({ avatar, descriptionGroupList, tokenLimit = 0, name, searchWords = [], endPointName, showEndPointName = false, className, }) => { const [FLAGS] = useFlags(); const tags: OptionItemTag[] = []; const shouldShowEndPoint = showEndPointName && endPointName; // 即将支持,敬请期待 const displayName = FLAGS['bot.studio.model_select_switch_end_point_name_pos'] ? endPointName || name : name; // 即将支持,敬请期待 const displayEndPointName = FLAGS[ 'bot.studio.model_select_switch_end_point_name_pos' ] ? name : endPointName; return ( {descriptionGroupList?.length ? ( } > ) : null} {(tokenLimit / 1024).toFixed(0)}K {shouldShowEndPoint ? ( ) : null} {tags?.length ? ( {tags.map(tag => ( {tag.label} ))} ) : null} ); };