ModelDetailSideSheet.jsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React from 'react';
  16. import { SideSheet, Typography, Button } from '@douyinfe/semi-ui';
  17. import { IconClose } from '@douyinfe/semi-icons';
  18. import { useIsMobile } from '../../../../hooks/common/useIsMobile';
  19. import ModelHeader from './components/ModelHeader';
  20. import ModelBasicInfo from './components/ModelBasicInfo';
  21. import ModelEndpoints from './components/ModelEndpoints';
  22. import ModelPricingTable from './components/ModelPricingTable';
  23. import DynamicPricingBreakdown from './components/DynamicPricingBreakdown';
  24. const { Text } = Typography;
  25. const ModelDetailSideSheet = ({
  26. visible,
  27. onClose,
  28. modelData,
  29. groupRatio,
  30. currency,
  31. siteDisplayType,
  32. tokenUnit,
  33. displayPrice,
  34. showRatio,
  35. usableGroup,
  36. vendorsMap,
  37. endpointMap,
  38. autoGroups,
  39. t,
  40. }) => {
  41. const isMobile = useIsMobile();
  42. return (
  43. <SideSheet
  44. placement='right'
  45. title={
  46. <ModelHeader modelData={modelData} vendorsMap={vendorsMap} t={t} />
  47. }
  48. bodyStyle={{
  49. padding: '0',
  50. display: 'flex',
  51. flexDirection: 'column',
  52. borderBottom: '1px solid var(--semi-color-border)',
  53. }}
  54. visible={visible}
  55. width={isMobile ? '100%' : 600}
  56. closeIcon={
  57. <Button
  58. className='semi-button-tertiary semi-button-size-small semi-button-borderless'
  59. type='button'
  60. icon={<IconClose />}
  61. onClick={onClose}
  62. />
  63. }
  64. onCancel={onClose}
  65. >
  66. <div className='p-2'>
  67. {!modelData && (
  68. <div className='flex justify-center items-center py-10'>
  69. <Text type='secondary'>{t('加载中...')}</Text>
  70. </div>
  71. )}
  72. {modelData && (
  73. <>
  74. <ModelBasicInfo
  75. modelData={modelData}
  76. vendorsMap={vendorsMap}
  77. t={t}
  78. />
  79. <ModelEndpoints
  80. modelData={modelData}
  81. endpointMap={endpointMap}
  82. t={t}
  83. />
  84. {modelData.billing_mode === 'tiered_expr' && modelData.billing_expr && (
  85. <DynamicPricingBreakdown
  86. billingExpr={modelData.billing_expr}
  87. t={t}
  88. />
  89. )}
  90. <ModelPricingTable
  91. modelData={modelData}
  92. groupRatio={groupRatio}
  93. currency={currency}
  94. siteDisplayType={siteDisplayType}
  95. tokenUnit={tokenUnit}
  96. displayPrice={displayPrice}
  97. showRatio={showRatio}
  98. usableGroup={usableGroup}
  99. autoGroups={autoGroups}
  100. t={t}
  101. />
  102. </>
  103. )}
  104. </div>
  105. </SideSheet>
  106. );
  107. };
  108. export default ModelDetailSideSheet;