mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-10 08:03:41 +08:00
Merge branch 'main' into refactor-settings-operation
This commit is contained in:
33
web/src/helpers/data.js
Normal file
33
web/src/helpers/data.js
Normal file
@@ -0,0 +1,33 @@
|
||||
export function setStatusData(data) {
|
||||
localStorage.setItem('status', JSON.stringify(data));
|
||||
localStorage.setItem('system_name', data.system_name);
|
||||
localStorage.setItem('logo', data.logo);
|
||||
localStorage.setItem('footer_html', data.footer_html);
|
||||
localStorage.setItem('quota_per_unit', data.quota_per_unit);
|
||||
localStorage.setItem('display_in_currency', data.display_in_currency);
|
||||
localStorage.setItem('enable_drawing', data.enable_drawing);
|
||||
localStorage.setItem('enable_data_export', data.enable_data_export);
|
||||
localStorage.setItem(
|
||||
'data_export_default_time',
|
||||
data.data_export_default_time,
|
||||
);
|
||||
localStorage.setItem(
|
||||
'default_collapse_sidebar',
|
||||
data.default_collapse_sidebar,
|
||||
);
|
||||
localStorage.setItem('mj_notify_enabled', data.mj_notify_enabled);
|
||||
if (data.chat_link) {
|
||||
localStorage.setItem('chat_link', data.chat_link);
|
||||
} else {
|
||||
localStorage.removeItem('chat_link');
|
||||
}
|
||||
if (data.chat_link2) {
|
||||
localStorage.setItem('chat_link2', data.chat_link2);
|
||||
} else {
|
||||
localStorage.removeItem('chat_link2');
|
||||
}
|
||||
}
|
||||
|
||||
export function setUserData(data) {
|
||||
localStorage.setItem('user', JSON.stringify(data));
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Label } from 'semantic-ui-react';
|
||||
import { Tag } from '@douyinfe/semi-ui';
|
||||
|
||||
export function renderText(text, limit) {
|
||||
@@ -136,6 +135,8 @@ export function renderQuota(quota, digits = 2) {
|
||||
}
|
||||
|
||||
export function renderModelPrice(
|
||||
inputTokens,
|
||||
completionTokens,
|
||||
modelRatio,
|
||||
modelPrice = -1,
|
||||
completionRatio,
|
||||
@@ -148,15 +149,24 @@ export function renderModelPrice(
|
||||
if (completionRatio === undefined) {
|
||||
completionRatio = 0;
|
||||
}
|
||||
let inputRatioPrice = modelRatio * 0.002 * groupRatio;
|
||||
let completionRatioPrice =
|
||||
modelRatio * completionRatio * 0.002 * groupRatio;
|
||||
let inputRatioPrice = modelRatio * 2.0 * groupRatio;
|
||||
let completionRatioPrice = modelRatio * completionRatio * 2.0 * groupRatio;
|
||||
let price =
|
||||
(inputTokens / 1000000) * inputRatioPrice +
|
||||
(completionTokens / 1000000) * completionRatioPrice;
|
||||
return (
|
||||
'输入:$' +
|
||||
inputRatioPrice.toFixed(3) +
|
||||
'/1K tokens,补全:$' +
|
||||
completionRatioPrice.toFixed(3) +
|
||||
'/1K tokens'
|
||||
<>
|
||||
<article>
|
||||
<p>提示 ${inputRatioPrice} / 1M tokens</p>
|
||||
<p>补全 ${completionRatioPrice} / 1M tokens</p>
|
||||
<p></p>
|
||||
<p>
|
||||
提示 {inputTokens} tokens / 1M tokens * ${inputRatioPrice} + 补全{' '}
|
||||
{completionTokens} tokens / 1M tokens * ${completionRatioPrice} = $
|
||||
{price.toFixed(6)}
|
||||
</p>
|
||||
</article>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user