refactor: update variable names and improve code readability; add Makefile for linting and installation

This commit is contained in:
Laisky.Cai
2025-01-23 03:32:41 +00:00
parent 81153f764b
commit 531f832d1e
12 changed files with 659 additions and 60 deletions

View File

@@ -380,14 +380,14 @@ const ChannelsTable = () => {
setShowPrompt(false);
setPromptShown(promptID);
}}>
OpenAI Channel已经不再支持通过 key 获取Balance因此Balance显示为 0对于支持的ChannelType请点击Balance进行Refresh
OpenAI Channel no longer supports getting Balance via key, so Balance is shown as 0. For supported ChannelTypes, please click Balance to Refresh.
<br/>
ChannelTest仅支持 chat Model优先使用 gpt-3.5-turbo如果该Model不可用则使用你所配置的Model列表中的第一个Model
ChannelTest only supports chat Models, preferring gpt-3.5-turbo. If this Model is not available, it will use the first Model in your configured Model list.
<br/>
点击下方Details按钮可以显示Balance以及Settings额外的TestModel
Click the Details button below to display Balance and additional TestModel Settings.
</Message>
)
}
)
}
<Table basic compact size='small'>
<Table.Header>
<Table.Row>
@@ -454,7 +454,7 @@ const ChannelsTable = () => {
sortChannel('priority');
}}
>
优先级
Priority
</Table.HeaderCell>
<Table.HeaderCell hidden={!showDetail}>TestModel</Table.HeaderCell>
<Table.HeaderCell>Operation</Table.HeaderCell>
@@ -491,7 +491,7 @@ const ChannelsTable = () => {
}} style={{ cursor: 'pointer' }}>
{renderBalance(channel.type, channel.balance)}
</span>}
content='点击更新'
content='Click to refresh'
basic
/>
</Table.Cell>
@@ -507,8 +507,7 @@ const ChannelsTable = () => {
}}>
<input style={{ maxWidth: '60px' }} />
</Input>}
content='Channel选择优先级,越高越优先'
basic
content='Channel priority - higher value means higher priority'
/>
</Table.Cell>
<Table.Cell hidden={!showDetail}>

View File

@@ -319,7 +319,7 @@ const LogsTable = () => {
}}
width={1}
>
费用
Cost
</Table.HeaderCell>
<Table.HeaderCell
style={{ cursor: 'pointer' }}

View File

@@ -107,7 +107,7 @@ const OperationSetting = () => {
}
if (originInputs['CompletionRatio'] !== inputs.CompletionRatio) {
if (!verifyJSON(inputs.CompletionRatio)) {
showError('Completion倍率不是合法的 JSON 字符串');
showError('Completion ratio is not a valid JSON string');
return;
}
await updateOption('CompletionRatio', inputs.CompletionRatio);
@@ -149,10 +149,10 @@ const OperationSetting = () => {
const res = await API.delete(`/api/log/?target_timestamp=${Date.parse(historyTimestamp) / 1000}`);
const { success, message, data } = res.data;
if (success) {
showSuccess(`${data} 条Logs已清理`);
showSuccess(`$cleared {data} logs!`);
return;
}
showError('Logs清理失败' + message);
showError('Failed to clear logs' + message);
};
return (
@@ -192,7 +192,7 @@ const OperationSetting = () => {
placeholder='Quota that can be exchanged for one unit of currency'
/>
<Form.Input
label='失败Retry次数'
label='Retry Times on Failure'
name='RetryTimes'
type={'number'}
step='1'
@@ -200,7 +200,7 @@ const OperationSetting = () => {
onChange={handleInputChange}
autoComplete='new-password'
value={inputs.RetryTimes}
placeholder='失败Retry次数'
placeholder='Number of retry attempts on failure'
/>
</Form.Group>
<Form.Group inline>
@@ -239,7 +239,7 @@ const OperationSetting = () => {
/>
</Form.Group>
<Form.Group widths={4}>
<Form.Input label='目标Time' value={historyTimestamp} type='datetime-local'
<Form.Input label='Target Time' value={historyTimestamp} type='datetime-local'
name='history_timestamp'
onChange={(e, { name, value }) => {
setHistoryTimestamp(value);
@@ -247,7 +247,7 @@ const OperationSetting = () => {
</Form.Group>
<Form.Button onClick={() => {
deleteHistoryLogs().then();
}}>清理历史Logs</Form.Button>
}}>Clear History Logs</Form.Button>
<Divider />
<Header as='h3'>
Monitoring Settings
@@ -357,13 +357,13 @@ const OperationSetting = () => {
</Form.Group>
<Form.Group widths='equal'>
<Form.TextArea
label='Completion倍率'
label='Completion Ratio'
name='CompletionRatio'
onChange={handleInputChange}
style={{ minHeight: 250, fontFamily: 'JetBrains Mono, Consolas' }}
autoComplete='new-password'
value={inputs.CompletionRatio}
placeholder='Is a JSON textKey is model nameValue is the rate此处的Rate Settings是ModelCompletion倍率相较于Prompt倍率的比例使用该Settings可强制覆盖 One API 的内部比例'
placeholder='Should be a JSON text, where keys are model names and values are ratios. This ratio setting represents the proportion of ModelCompletion rate to Prompt rate, which can forcefully override One API internal ratios'
/>
</Form.Group>
<Form.Group widths='equal'>

View File

@@ -140,15 +140,15 @@ const OtherSetting = () => {
<Form.Button onClick={submitSystemName}>Set system name</Form.Button>
<Form.Group widths='equal'>
<Form.Input
label={<label>主题Name<Link
to='https://github.com/songquanpeng/one-api/blob/main/web/README.md'>当前可用主题</Link></label>}
placeholder='请Enter主题Name'
label={<label>Theme Name (<Link
to='https://github.com/songquanpeng/one-api/blob/main/web/README.md'>Available Themes</Link>)</label>}
placeholder='Please enter theme name'
value={inputs.Theme}
name='Theme'
onChange={handleInputChange}
/>
</Form.Group>
<Form.Button onClick={submitTheme}>Settings主题重启生效</Form.Button>
<Form.Button onClick={submitTheme}>Set Theme (Restart Required)</Form.Button>
<Form.Group widths='equal'>
<Form.Input
label='Logo Image URL'
@@ -182,8 +182,7 @@ const OtherSetting = () => {
/>
</Form.Group>
<Form.Button onClick={submitAbout}>Save About</Form.Button>
<Message>移除 One API
的版权标识必须首先获得授权项目维护需要花费大量精力如果本项目对你有意义请主动支持本项目</Message>
<Message>Removing One API's copyright notice requires prior authorization. Project maintenance requires significant effort - if this project is meaningful to you, please actively support it.</Message>
<Form.Group widths='equal'>
<Form.Input
label='Footer'

View File

@@ -63,7 +63,7 @@ const PersonalSetting = () => {
const { success, message, data } = res.data;
if (success) {
setSystemToken(data);
setAffLink("");
setAffLink("");
await copy(data);
showSuccess(`Token has been reset and copied to the clipboard`);
} else {
@@ -180,22 +180,22 @@ const PersonalSetting = () => {
<Button onClick={getAffLink}>Copy invitation link</Button>
<Button onClick={() => {
setShowAccountDeleteModal(true);
}}>Delete个人账户</Button>
}}>Delete Account</Button>
{systemToken && (
<Form.Input
fluid
readOnly
value={systemToken}
<Form.Input
fluid
readOnly
value={systemToken}
onClick={handleSystemTokenClick}
style={{ marginTop: '10px' }}
/>
)}
{affLink && (
<Form.Input
fluid
readOnly
value={affLink}
<Form.Input
fluid
readOnly
value={affLink}
onClick={handleAffLinkClick}
style={{ marginTop: '10px' }}
/>
@@ -309,7 +309,7 @@ const PersonalSetting = () => {
>
Confirm binding
</Button>
<div style={{ width: '1rem' }}></div>
<div style={{ width: '1rem' }}></div>
<Button
fluid
size='large'

View File

@@ -264,7 +264,7 @@ const EditChannel = () => {
<Form.Input
label='Default API Version'
name='other'
placeholder={'请EnterDefault API VersionFor example2024-03-01-preview该配置可以被实际的请求Query参数所覆盖'}
placeholder={'Please enter default API version, for example: 2024-03-01-preview. This configuration can be overridden by actual request query parameters'}
onChange={handleInputChange}
value={inputs.other}
autoComplete='new-password'
@@ -301,7 +301,7 @@ const EditChannel = () => {
<Form.Field>
<Form.Dropdown
label='Group'
placeholder={'请选择可以使用该Channel的Group'}
placeholder={'Please select the Group that can use this Channel'}
name='groups'
required
fluid
@@ -333,9 +333,9 @@ const EditChannel = () => {
inputs.type === 21 && (
<Form.Field>
<Form.Input
label='知识库 ID'
label='Knowledge Base ID'
name='other'
placeholder={'请Enter知识库 IDFor example123456'}
placeholder={'Please enter Knowledge Base ID, for example: 123456'}
onChange={handleInputChange}
value={inputs.other}
autoComplete='new-password'
@@ -347,9 +347,9 @@ const EditChannel = () => {
inputs.type === 17 && (
<Form.Field>
<Form.Input
label='插件参数'
label='Plugin Parameters'
name='other'
placeholder={'请Enter插件参数 X-DashScope-Plugin 请求头的取值'}
placeholder={'Please enter plugin parameters, i.e., the value of the X-DashScope-Plugin request header'}
onChange={handleInputChange}
value={inputs.other}
autoComplete='new-password'
@@ -360,14 +360,14 @@ const EditChannel = () => {
{
inputs.type === 34 && (
<Message>
对于 Coze 而言Model name Bot ID你可以添加一个前缀 `bot-`For example`bot-123456`
For Coze, the Model name is the Bot ID. You can add a prefix `bot-`, for example: `bot-123456`.
</Message>
)
}
{
inputs.type === 40 && (
<Message>
对于豆包而言需要手动去 <a target="_blank" href="https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint">Model推理页面</a> NameModel nameFor example`ep-20240608051426-tkxvl`
For Doubao, you need to manually create an inference endpoint on the <a target="_blank" href="https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint">Model Inference Page</a>. Use the endpoint Name as the Model name, for example: `ep-20240608051426-tkxvl`.
</Message>
)
}
@@ -399,7 +399,7 @@ const EditChannel = () => {
<div style={{ lineHeight: '40px', marginBottom: '12px' }}>
<Button type={'button'} onClick={() => {
handleInputChange(null, { name: 'models', value: basicModels });
}}>填入相关Model</Button>
}}>Fill in Related Models</Button>
<Button type={'button'} onClick={() => {
handleInputChange(null, { name: 'models', value: fullModels });
}}>Fill in all models</Button>
@@ -408,7 +408,7 @@ const EditChannel = () => {
}}>Clear all models</Button>
<Input
action={
<Button type={'button'} onClick={addCustomModel}>填入</Button>
<Button type={'button'} onClick={addCustomModel}>Fill in</Button>
}
placeholder='EnterCustomModel name'
value={customModel}
@@ -440,8 +440,8 @@ const EditChannel = () => {
</Form.Field>
<Form.Field>
<Form.TextArea
label='SystemPrompt'
placeholder={`此项可选用于强制Settings给定的SystemPrompt请配合CustomModel & Model redirection使用首先创建一个唯一的CustomModel name并在上面填入之后将该CustomModel redirection映射到该Channel一个原生支持的Model`}
label='System Prompt'
placeholder={`Optional: Used to force system prompt words specified in Settings. Use with CustomModel & Model redirection - first create a unique CustomModel name and fill it above, then map that CustomModel redirection to a natively supported Model on this Channel`}
name='system_prompt'
onChange={handleInputChange}
value={inputs.system_prompt}
@@ -524,7 +524,7 @@ const EditChannel = () => {
label='User ID'
name='user_id'
required
placeholder={'生成该Key的Users ID'}
placeholder={'User ID that generated this Key'}
onChange={handleConfigChange}
value={config.user_id}
autoComplete=''
@@ -561,7 +561,7 @@ const EditChannel = () => {
label='Account ID'
name='user_id'
required
placeholder={'Enter Account IDFor exampled8d7c61dbc334c32d3ced580e4bf42b4'}
placeholder={'Enter Account IDFor exampled8d7c61dbc334c32d3ced580e4bf42b4'}
onChange={handleConfigChange}
value={config.user_id}
autoComplete=''
@@ -597,9 +597,9 @@ const EditChannel = () => {
inputs.type === 22 && (
<Form.Field>
<Form.Input
label='私有部署地址'
label='Private Deployment URL'
name='base_url'
placeholder={'请Enter私有部署地址格式为https://fastgpt.run/api/openapi'}
placeholder={'Please enter the private deployment URL, format: https://fastgpt.run/api/openapi'}
onChange={handleInputChange}
value={inputs.base_url}
autoComplete='new-password'