+ {
+ (modelItem.key === ProviderEnum.minimax || modelItem.key === ProviderEnum.spark) && systemFree && !systemFree?.is_valid && !IS_CE_EDITION && (
+
+ )
+ }
{
modelItem.disable && !IS_CE_EDITION && (
diff --git a/web/app/components/header/account-setting/model-page/model-item/index.tsx b/web/app/components/header/account-setting/model-page/model-item/index.tsx
index 1bcd0cd4f..e8cb63c25 100644
--- a/web/app/components/header/account-setting/model-page/model-item/index.tsx
+++ b/web/app/components/header/account-setting/model-page/model-item/index.tsx
@@ -26,6 +26,7 @@ const ModelItem: FC = ({
modelItem,
onOpenModal,
onOperate,
+ onUpdate,
}) => {
const { locale } = useContext(I18n)
const custom = currentProvider?.providers.find(p => p.provider_type === 'custom') as ProviderWithModels
@@ -47,6 +48,7 @@ const ModelItem: FC = ({
modelItem={modelItem}
onOpenModal={onOpenModal}
onOperate={onOperate}
+ onUpdate={onUpdate}
/>
{
diff --git a/web/config/index.ts b/web/config/index.ts
index 991de2e6d..82908b355 100644
--- a/web/config/index.ts
+++ b/web/config/index.ts
@@ -120,3 +120,4 @@ export const VAR_ITEM_TEMPLATE = {
export const appDefaultIconBackground = '#D5F5F6'
export const NEED_REFRESH_APP_LIST_KEY = 'needRefreshAppList'
+export const SPARK_FREE_QUOTA_PENDING = 'sparkFreeQuotaPending'
diff --git a/web/i18n/lang/app-overview.en.ts b/web/i18n/lang/app-overview.en.ts
index 9fb0dca05..23ce0d019 100644
--- a/web/i18n/lang/app-overview.en.ts
+++ b/web/i18n/lang/app-overview.en.ts
@@ -23,6 +23,7 @@ const translation = {
},
},
callTimes: 'Call times',
+ usedToken: 'Used token',
setAPIBtn: 'Go to setup model provider',
tryCloud: 'Or try the cloud version of Dify with free quote',
},
diff --git a/web/i18n/lang/app-overview.zh.ts b/web/i18n/lang/app-overview.zh.ts
index 957b08d4b..82a7ccaa5 100644
--- a/web/i18n/lang/app-overview.zh.ts
+++ b/web/i18n/lang/app-overview.zh.ts
@@ -23,6 +23,7 @@ const translation = {
},
},
callTimes: '调用次数',
+ usedToken: '使用 Tokens',
setAPIBtn: '设置模型提供商',
tryCloud: '或者尝试使用 Dify 的云版本并使用试用配额',
},
diff --git a/web/i18n/lang/common.en.ts b/web/i18n/lang/common.en.ts
index a2ff78079..e197d05be 100644
--- a/web/i18n/lang/common.en.ts
+++ b/web/i18n/lang/common.en.ts
@@ -25,6 +25,7 @@ const translation = {
download: 'Download',
setup: 'Setup',
getForFree: 'Get for free',
+ reload: 'Reload',
},
placeholder: {
input: 'Please enter',
diff --git a/web/i18n/lang/common.zh.ts b/web/i18n/lang/common.zh.ts
index 5ff5bdcd0..855d634b4 100644
--- a/web/i18n/lang/common.zh.ts
+++ b/web/i18n/lang/common.zh.ts
@@ -25,6 +25,7 @@ const translation = {
download: '下载',
setup: '设置',
getForFree: '免费获取',
+ reload: '刷新',
},
placeholder: {
input: '请输入',
diff --git a/web/service/common.ts b/web/service/common.ts
index 646607375..d66fe166a 100644
--- a/web/service/common.ts
+++ b/web/service/common.ts
@@ -169,3 +169,7 @@ export const fetchDefaultModal: Fetcher
= (url) => {
export const updateDefaultModel: Fetcher = ({ url, body }) => {
return post(url, { body }) as Promise
}
+
+export const submitFreeQuota: Fetcher<{ type: string; redirect_url?: string; result?: string }, string> = (url) => {
+ return post(url) as Promise<{ type: string; redirect_url?: string; result?: string }>
+}
diff --git a/web/utils/format.ts b/web/utils/format.ts
index fc30c6236..1eeb6af80 100644
--- a/web/utils/format.ts
+++ b/web/utils/format.ts
@@ -1,33 +1,36 @@
/*
-* Formats a number with comma separators.
+* Formats a number with comma separators.
formatNumber(1234567) will return '1,234,567'
formatNumber(1234567.89) will return '1,234,567.89'
*/
export const formatNumber = (num: number | string) => {
- if (!num) return num;
- let parts = num.toString().split(".");
- parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- return parts.join(".");
+ if (!num)
+ return num
+ const parts = num.toString().split('.')
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
+ return parts.join('.')
}
export const formatFileSize = (num: number) => {
- if (!num) return num;
- const units = ['', 'K', 'M', 'G', 'T', 'P'];
- let index = 0;
+ if (!num)
+ return num
+ const units = ['', 'K', 'M', 'G', 'T', 'P']
+ let index = 0
while (num >= 1024 && index < units.length) {
- num = num / 1024;
- index++;
+ num = num / 1024
+ index++
}
- return num.toFixed(2) + `${units[index]}B`;
+ return `${num.toFixed(2)}${units[index]}B`
}
export const formatTime = (num: number) => {
- if (!num) return num;
- const units = ['sec', 'min', 'h'];
- let index = 0;
+ if (!num)
+ return num
+ const units = ['sec', 'min', 'h']
+ let index = 0
while (num >= 60 && index < units.length) {
- num = num / 60;
- index++;
+ num = num / 60
+ index++
}
- return `${num.toFixed(2)} ${units[index]}`;
+ return `${num.toFixed(2)} ${units[index]}`
}