diff --git a/src/components/chat-view/ChatView.tsx b/src/components/chat-view/ChatView.tsx index bca627a..75d50c7 100644 --- a/src/components/chat-view/ChatView.tsx +++ b/src/components/chat-view/ChatView.tsx @@ -30,6 +30,7 @@ import { } from '../../core/llm/exception' import { regexSearchFiles } from '../../core/ripgrep' import { useChatHistory } from '../../hooks/use-chat-history' +import { useCustomModes } from '../../hooks/use-custom-mode' import { ApplyStatus, ToolArgs } from '../../types/apply' import { ChatMessage, ChatUserMessage } from '../../types/chat' import { @@ -101,6 +102,7 @@ const Chat = forwardRef((props, ref) => { const { settings, setSettings } = useSettings() const { getRAGEngine } = useRAG() const diffStrategy = useDiffStrategy() + const { customModeList, customModePrompts } = useCustomModes() const { createOrUpdateConversation, @@ -112,8 +114,8 @@ const Chat = forwardRef((props, ref) => { const { streamResponse, chatModel } = useLLM() const promptGenerator = useMemo(() => { - return new PromptGenerator(getRAGEngine, app, settings, diffStrategy) - }, [getRAGEngine, app, settings, diffStrategy]) + return new PromptGenerator(getRAGEngine, app, settings, diffStrategy, customModePrompts, customModeList) + }, [getRAGEngine, app, settings, diffStrategy, customModePrompts, customModeList]) const [inputMessage, setInputMessage] = useState(() => { const newMessage = getNewInputMessage(app, settings.defaultMention) diff --git a/src/components/chat-view/CustomModeView.tsx b/src/components/chat-view/CustomModeView.tsx index cc45c0b..9e6f2ba 100644 --- a/src/components/chat-view/CustomModeView.tsx +++ b/src/components/chat-view/CustomModeView.tsx @@ -1,10 +1,14 @@ -import { Plus, Undo2, Settings, Circle, Trash2 } from 'lucide-react'; -import React, { useState, useEffect } from 'react'; +import { ChevronDown, ChevronRight, Plus, Trash2, Undo2 } from 'lucide-react'; +import React, { useEffect, useState } from 'react'; +import { useApp } from '../../contexts/AppContext'; +import { CustomMode, GroupEntry, ToolGroup } from '../../database/json/custom-mode/types'; import { useCustomModes } from '../../hooks/use-custom-mode'; -import { CustomMode, ToolGroup, toolGroups, GroupEntry } from '../../database/json/custom-mode/types'; import { modes as buildinModes } from '../../utils/modes'; +import { openOrCreateMarkdownFile } from '../../utils/obsidian'; const CustomModeView = () => { + const app = useApp() + const { createCustomMode, deleteCustomMode, @@ -15,7 +19,7 @@ const CustomModeView = () => { // 当前选择的模式 const [selectedMode, setSelectedMode] = useState('ask') const [isBuiltinMode, setIsBuiltinMode] = useState(true) - + const [isAdvancedCollapsed, setIsAdvancedCollapsed] = useState(true); const isNewMode = React.useMemo(() => selectedMode === "add_new_mode", [selectedMode]) @@ -46,7 +50,6 @@ const CustomModeView = () => { // 自定义指令 const [customInstructions, setCustomInstructions] = useState('') - // 当模式变更时更新表单数据 useEffect(() => { // new mode @@ -63,7 +66,7 @@ const CustomModeView = () => { const builtinMode = buildinModes.find(m => m.slug === selectedMode); if (builtinMode) { setIsBuiltinMode(true); - setModeName(builtinMode.name); + setModeName(builtinMode.slug); setRoleDefinition(builtinMode.roleDefinition); setCustomInstructions(builtinMode.customInstructions || ''); setSelectedTools(builtinMode.groups as GroupEntry[]); @@ -219,9 +222,11 @@ const CustomModeView = () => {

角色定义

- + {isBuiltinMode && ( + + )}

设定专业领域和应答风格