translate custom mode config view to english

This commit is contained in:
duanfuxiang 2025-04-29 18:37:26 +08:00
parent 16cd3a8691
commit 3ec2873166
2 changed files with 98 additions and 47 deletions

View File

@ -33,14 +33,14 @@ const CustomModeView = () => {
return new PromptGenerator(getRAGEngine, app, settings, diffStrategy, customModePrompts, customModeList) return new PromptGenerator(getRAGEngine, app, settings, diffStrategy, customModePrompts, customModeList)
}, [app, settings, diffStrategy, customModePrompts, customModeList]) }, [app, settings, diffStrategy, customModePrompts, customModeList])
// 当前选择的模式 // Currently selected mode
const [selectedMode, setSelectedMode] = useState<string>('ask') const [selectedMode, setSelectedMode] = useState<string>('ask')
const [isBuiltinMode, setIsBuiltinMode] = useState<boolean>(true) const [isBuiltinMode, setIsBuiltinMode] = useState<boolean>(true)
const [isAdvancedCollapsed, setIsAdvancedCollapsed] = useState(false); const [isAdvancedCollapsed, setIsAdvancedCollapsed] = useState(true);
const isNewMode = React.useMemo(() => selectedMode === "add_new_mode", [selectedMode]) const isNewMode = React.useMemo(() => selectedMode === "add_new_mode", [selectedMode])
// new mode config // New mode configuration
const [newMode, setNewMode] = useState<CustomMode>({ const [newMode, setNewMode] = useState<CustomMode>({
id: '', id: '',
slug: '', slug: '',
@ -52,22 +52,22 @@ const CustomModeView = () => {
updatedAt: 0, updatedAt: 0,
}) })
// custom mode id // Custom mode ID
const [customModeId, setCustomModeId] = useState<string>('') const [customModeId, setCustomModeId] = useState<string>('')
// 模型名称 // Mode name
const [modeName, setModeName] = useState<string>('') const [modeName, setModeName] = useState<string>('')
// 角色定义 // Role definition
const [roleDefinition, setRoleDefinition] = useState<string>('') const [roleDefinition, setRoleDefinition] = useState<string>('')
// 选中的工具组 // Selected tool groups
const [selectedTools, setSelectedTools] = useState<GroupEntry[]>([]) const [selectedTools, setSelectedTools] = useState<GroupEntry[]>([])
// 自定义指令 // Custom instructions
const [customInstructions, setCustomInstructions] = useState<string>('') const [customInstructions, setCustomInstructions] = useState<string>('')
// 当模式变更时更新表单数据 // Update form data when mode changes
useEffect(() => { useEffect(() => {
// new mode // new mode
if (isNewMode) { if (isNewMode) {
@ -87,7 +87,7 @@ const CustomModeView = () => {
setRoleDefinition(builtinMode.roleDefinition); setRoleDefinition(builtinMode.roleDefinition);
setCustomInstructions(builtinMode.customInstructions || ''); setCustomInstructions(builtinMode.customInstructions || '');
setSelectedTools(builtinMode.groups as GroupEntry[]); setSelectedTools(builtinMode.groups as GroupEntry[]);
setCustomModeId(''); // 内置模式没有自定义 ID setCustomModeId(''); // Built-in modes don't have custom IDs
} else { } else {
setIsBuiltinMode(false); setIsBuiltinMode(false);
const customMode = customModeList.find(m => m.slug === selectedMode); const customMode = customModeList.find(m => m.slug === selectedMode);
@ -104,7 +104,7 @@ const CustomModeView = () => {
}, [selectedMode, customModeList]); }, [selectedMode, customModeList]);
// 处理工具组选择变更 // Handle tool group selection change
const handleToolChange = React.useCallback((tool: ToolGroup) => { const handleToolChange = React.useCallback((tool: ToolGroup) => {
if (isNewMode) { if (isNewMode) {
setNewMode((prev) => ({ setNewMode((prev) => ({
@ -121,7 +121,7 @@ const CustomModeView = () => {
}); });
}, [isNewMode]) }, [isNewMode])
// 更新模式配置 // Update mode configuration
const handleUpdateMode = React.useCallback(async () => { const handleUpdateMode = React.useCallback(async () => {
if (!isBuiltinMode) { if (!isBuiltinMode) {
await updateCustomMode( await updateCustomMode(
@ -134,7 +134,7 @@ const CustomModeView = () => {
} }
}, [isBuiltinMode, customModeId, modeName, roleDefinition, customInstructions, selectedTools]) }, [isBuiltinMode, customModeId, modeName, roleDefinition, customInstructions, selectedTools])
// 创建新模式 // Create new mode
const createNewMode = React.useCallback(async () => { const createNewMode = React.useCallback(async () => {
if (!isNewMode) return; if (!isNewMode) return;
await createCustomMode( await createCustomMode(
@ -157,7 +157,7 @@ const CustomModeView = () => {
setSelectedMode("add_new_mode") setSelectedMode("add_new_mode")
}, [isNewMode, modeName, roleDefinition, customInstructions, selectedTools]) }, [isNewMode, modeName, roleDefinition, customInstructions, selectedTools])
// 删除模式 // Delete mode
const deleteMode = React.useCallback(async () => { const deleteMode = React.useCallback(async () => {
if (isNewMode || isBuiltinMode) return; if (isNewMode || isBuiltinMode) return;
await deleteCustomMode(customModeId); await deleteCustomMode(customModeId);
@ -170,10 +170,10 @@ const CustomModeView = () => {
return ( return (
<div className="infio-custom-modes-container"> <div className="infio-custom-modes-container">
{/* 模式配置标题和按钮 */} {/* Mode configuration title and buttons */}
<div className="infio-custom-modes-header"> <div className="infio-custom-modes-header">
<div className="infio-custom-modes-title"> <div className="infio-custom-modes-title">
<h2></h2> <h2>Mode Configuration</h2>
</div> </div>
{/* <div className="infio-custom-modes-actions"> {/* <div className="infio-custom-modes-actions">
<button className="infio-custom-modes-btn"> <button className="infio-custom-modes-btn">
@ -185,12 +185,12 @@ const CustomModeView = () => {
</div> */} </div> */}
</div> </div>
{/* 创建模式提示 */} {/* Create mode tip */}
<div className="infio-custom-modes-tip"> <div className="infio-custom-modes-tip">
+ Click + to create a new mode
</div> </div>
{/* 模式选择区 */} {/* Mode selection area */}
<div className="infio-custom-modes-builtin"> <div className="infio-custom-modes-builtin">
{[...buildinModes, ...customModeList].map(mode => ( {[...buildinModes, ...customModeList].map(mode => (
<button <button
@ -210,10 +210,10 @@ const CustomModeView = () => {
</button> </button>
</div> </div>
{/* 模式名称 */} {/* Mode name */}
<div className="infio-custom-modes-section"> <div className="infio-custom-modes-section">
<div className="infio-section-header"> <div className="infio-section-header">
<h3></h3> <h3>Mode Name</h3>
{!isBuiltinMode && !isNewMode && ( {!isBuiltinMode && !isNewMode && (
<button className="infio-section-btn" onClick={deleteMode}> <button className="infio-section-btn" onClick={deleteMode}>
<Trash2 size={16} /> <Trash2 size={16} />
@ -221,8 +221,12 @@ const CustomModeView = () => {
)} )}
</div> </div>
{ {
isBuiltinMode && ( isBuiltinMode ? (
<p className="infio-section-subtitle"></p> <p className="infio-section-subtitle">Built-in mode names cannot be modified</p>
) : (
<p className="infio-section-subtitle">
Mode names must only contain letters, numbers, and hyphens
</p>
) )
} }
<input <input
@ -235,22 +239,22 @@ const CustomModeView = () => {
setModeName(e.target.value) setModeName(e.target.value)
}} }}
className="infio-custom-modes-input" className="infio-custom-modes-input"
placeholder="输入模式名称..." placeholder="Enter mode name..."
disabled={isBuiltinMode} disabled={isBuiltinMode}
/> />
</div> </div>
{/* 角色定义 */} {/* Role definition */}
<div className="infio-custom-modes-section"> <div className="infio-custom-modes-section">
<div className="infio-section-header"> <div className="infio-section-header">
<h3></h3> <h3>Role Definition</h3>
{isBuiltinMode && ( {isBuiltinMode && (
<button className="infio-section-btn"> <button className="infio-section-btn">
<Undo2 size={16} /> <Undo2 size={16} />
</button> </button>
)} )}
</div> </div>
<p className="infio-section-subtitle"></p> <p className="infio-section-subtitle">Set professional domain and response style</p>
<textarea <textarea
className="infio-custom-textarea" className="infio-custom-textarea"
value={roleDefinition} value={roleDefinition}
@ -260,14 +264,14 @@ const CustomModeView = () => {
} }
setRoleDefinition(e.target.value) setRoleDefinition(e.target.value)
}} }}
placeholder="输入角色定义..." placeholder="Enter role definition..."
/> />
</div> </div>
{/* 可用功能 */} {/* Available features */}
<div className="infio-custom-modes-section"> <div className="infio-custom-modes-section">
<div className="infio-section-header"> <div className="infio-section-header">
<h3></h3> <h3>Available Features</h3>
{/* {!isBuiltinMode && ( {/* {!isBuiltinMode && (
<button className="infio-section-btn"> <button className="infio-section-btn">
<Undo2 size={16} /> <Undo2 size={16} />
@ -276,7 +280,7 @@ const CustomModeView = () => {
</div> </div>
{ {
isBuiltinMode && ( isBuiltinMode && (
<p className="infio-section-subtitle"></p> <p className="infio-section-subtitle">Available features of built-in modes cannot be modified</p>
) )
} }
<div className="infio-tools-list"> <div className="infio-tools-list">
@ -288,7 +292,7 @@ const CustomModeView = () => {
checked={selectedTools.includes('read')} checked={selectedTools.includes('read')}
onChange={() => handleToolChange('read')} onChange={() => handleToolChange('read')}
/> />
Read Files
</label> </label>
</div> </div>
<div className="infio-tool-item"> <div className="infio-tool-item">
@ -299,7 +303,7 @@ const CustomModeView = () => {
checked={selectedTools.includes('edit')} checked={selectedTools.includes('edit')}
onChange={() => handleToolChange('edit')} onChange={() => handleToolChange('edit')}
/> />
Edit Files
</label> </label>
</div> </div>
<div className="infio-tool-item"> <div className="infio-tool-item">
@ -310,18 +314,23 @@ const CustomModeView = () => {
checked={selectedTools.includes('research')} checked={selectedTools.includes('research')}
onChange={() => handleToolChange('research')} onChange={() => handleToolChange('research')}
/> />
Web Search
</label> </label>
</div> </div>
</div> </div>
</div> </div>
{/* 模式专属规则 */} {/* Mode-specific rules */}
<div className="infio-custom-modes-section"> <div className="infio-custom-modes-section">
<div className="infio-section-header"> <div className="infio-section-header">
<h3> </h3> <h3>Mode-Specific Rules (Optional)</h3>
{isBuiltinMode && (
<button className="infio-section-btn">
<Undo2 size={16} />
</button>
)}
</div> </div>
<p className="infio-section-subtitle"></p> <p className="infio-section-subtitle">Mode-specific rules</p>
<textarea <textarea
className="infio-custom-textarea" className="infio-custom-textarea"
value={customInstructions} value={customInstructions}
@ -331,14 +340,14 @@ const CustomModeView = () => {
} }
setCustomInstructions(e.target.value) setCustomInstructions(e.target.value)
}} }}
placeholder="输入模式自定义指令..." placeholder="Enter mode custom instructions..."
/> />
<p className="infio-section-footer"> <p className="infio-section-footer">
<a href="#" className="infio-link" onClick={() => openOrCreateMarkdownFile(app, `_infio_prompts/${modeName}/rules.md`, 0)}>_infio_prompts/{modeName}/rules</a> Support reading configuration from<a href="#" className="infio-link" onClick={() => openOrCreateMarkdownFile(app, `_infio_prompts/${modeName}/rules.md`, 0)}>_infio_prompts/{modeName}/rules</a> file
</p> </p>
</div> </div>
{/* 高级, 覆盖系统提示词 */} {/* Advanced, override system prompt */}
<div className="infio-custom-modes-section"> <div className="infio-custom-modes-section">
<div <div
className="infio-section-header infio-section-header-collapsible" className="infio-section-header infio-section-header-collapsible"
@ -346,15 +355,15 @@ const CustomModeView = () => {
> >
<div className="infio-section-header-title-container"> <div className="infio-section-header-title-container">
{isAdvancedCollapsed ? <ChevronRight size={16} /> : <ChevronDown size={16} />} {isAdvancedCollapsed ? <ChevronRight size={16} /> : <ChevronDown size={16} />}
<h6 className="infio-section-header-title"></h6> <h6 className="infio-section-header-title">Override System Prompt</h6>
</div> </div>
</div> </div>
{!isAdvancedCollapsed && ( {!isAdvancedCollapsed && (
<> <>
<p className="infio-section-subtitle"> <p className="infio-section-subtitle">
You can completely replace the system prompt for this mode (excluding role definition and custom instructions) by creating a file
<a href="#" className="infio-link" onClick={() => openOrCreateMarkdownFile(app, `_infio_prompts/${modeName}/system_prompt.md`, 0)}>_infio_prompts/{modeName}/system_prompt</a> <a href="#" className="infio-link" onClick={() => openOrCreateMarkdownFile(app, `_infio_prompts/${modeName}/system_prompt.md`, 0)}>_infio_prompts/{modeName}/system_prompt</a>
使, <button . This is a very advanced feature that will override all built-in prompts including tool usage, please use with caution <button
className="infio-preview-btn" className="infio-preview-btn"
onClick={async () => { onClick={async () => {
let filesSearchMethod = settings.filesSearchMethod let filesSearchMethod = settings.filesSearchMethod
@ -386,13 +395,13 @@ const CustomModeView = () => {
} }
} }
> >
Preview System Prompt
</button> </button>
</p></> </p></>
)} )}
</div> </div>
{/* 保存 */} {/* Save */}
<div className="infio-custom-modes-actions"> <div className="infio-custom-modes-actions">
<button <button
className="infio-preview-btn" className="infio-preview-btn"
@ -404,11 +413,11 @@ const CustomModeView = () => {
} }
}} }}
> >
Save
</button> </button>
</div> </div>
{/* 样式 */} {/* Styles */}
<style> <style>
{` {`
.infio-custom-modes-container { .infio-custom-modes-container {

View File

@ -504,6 +504,48 @@ export const deepSeekModels = {
export type QwenModelId = keyof typeof qwenModels export type QwenModelId = keyof typeof qwenModels
export const qwenDefaultModelId: QwenModelId = "qwen-max-latest" export const qwenDefaultModelId: QwenModelId = "qwen-max-latest"
export const qwenModels = { export const qwenModels = {
"qwen3-235b-a22b": {
maxTokens: 129_024,
contextWindow: 131_072,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.002,
outputPrice: 0.006,
cacheWritesPrice: 0.002,
cacheReadsPrice: 0.006,
},
"qwen3-32b": {
maxTokens: 129_024,
contextWindow: 131_072,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.002,
outputPrice: 0.006,
},
"qwen3-30b-a3b": {
maxTokens: 129_024,
contextWindow: 131_072,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.002,
outputPrice: 0.006,
},
"qwen3-14b": {
maxTokens: 129_024,
contextWindow: 131_072,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.002,
outputPrice: 0.006,
},
"qwen3-8b": {
maxTokens: 129_024,
contextWindow: 131_072,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.002,
outputPrice: 0.006,
},
"qwen2.5-coder-32b-instruct": { "qwen2.5-coder-32b-instruct": {
maxTokens: 8_192, maxTokens: 8_192,
contextWindow: 131_072, contextWindow: 131_072,