| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <template>
- <ChatMessageContainer
- :chatManager="chatManager"
- :sessionManager="sessionManager"
- :historyItemsPagerManager="historyItemsPagerManager"
- :chatInterfaceManager="interfaceManager"
- @intoSelectMode="intoSelectMode"
- >
- <template #header>
- <NavBar title="AI伴写" leftButton="menu" @leftButtonPressed="" />
- </template>
- <template #footer>
- <ChatFooter
- :chatManager="chatManager"
- />
- </template>
- </ChatMessageContainer>
- </template>
- <script setup lang="ts">
- import { onMounted, ref, type Ref } from 'vue';
- import { useChatSession } from '@/pages/chat/composables/useChatSession';
- import { useChat, type ChatInterfaceManager } from '@/pages/chat/core/Chat';
- import { useChatHistoryItemsPager } from '@/pages/chat/composables/useChatHistoryItemsPager';
- import { ChatMessage as ChatMessageModel } from '@/pages/chat/model/Message';
- import { ChatGroups } from '@/pages/chat/core/Groups';
- import ChatFooter from '../../chat/components/ChatFooter.vue';
- import ChatMessageContainer from '../../chat/components/ChatMessageContainer.vue';
- import FlexCol from '@/components/layout/FlexCol.vue';
- import NavBar from '@/components/nav/NavBar.vue';
- import { useChatSelection } from '@/pages/chat/composables/useChatSelection';
- const messages = ref<ChatMessageModel[]>([]) as Ref<ChatMessageModel[]>;
- const interfaceManager: ChatInterfaceManager = {
- messages,
- getAttachmentList: async () => {
- return [];
- },
- };
- const sessionManager = useChatSession({
- messages,
- enableSession: true,
- groupId: ChatGroups.NOTE_EDITOR,
- onStop: () => chatManager.stop(),
- onScrollToBottom: () => interfaceManager.scrollToBottom?.(),
- });
- const historyItemsPagerManager = useChatHistoryItemsPager({
- messages,
- sessionManager,
- });
- const chatManager = useChat({
- interfaceManager,
- sessionManager,
- config: {
- onGetSendOptions: () => ({
- enableThinking: false,
- enableSearch: true,
- modelInfo: {
- name: 'hunyuan-2.0-instruct-20251111',
- value: 'hunyuan-2.0-instruct-20251111',
- max_tokens: 10000,
- },
- model: 'hunyuan-2.0-instruct-20251111',
- chatOptions: {
- temperature: 0.5,
- top_p: 1,
- top_k: 40,
- presence_penalty: 0,
- },
- customSystemPrompt: '',
- }),
- defaultSystemPrompt: `你是一个“笔记/文章写作与改稿助手”,工作在一个笔记编辑器里。你需要在与用户对话的同时,能直接读取并修改当前文章(标题与正文)。
- ## 工作目标
- - 帮用户写作:构思、列提纲、扩写、续写、改写、润色、降重、统一文风、改错别字与语病。
- - 帮用户改稿:在不改变事实/观点的前提下,提高表达清晰度、逻辑性与可读性;必要时提出修改建议并给出可直接应用的改稿。
- ## 强制规则(很重要)
- - 当用户的需求涉及“基于现有文章内容”进行判断/总结/改写/润色/纠错/扩写时:你必须先调用工具读取文章(至少读取标题或正文)再开始。
- - 当需要改动文章时:优先使用“片段替换/插入/删除”等精确编辑工具;只有在大改(重写/大幅重排)时才使用整篇覆盖写入。
- - 任何工具写入后,都要简短说明你改了什么(1-3 条),避免长篇复述全文。
- - 如果用户只是在聊天,不需要动文章,就不要调用写入工具。
- ## 输出偏好
- - 先给结论/方案,再给要点;结构清晰,使用小标题与列表。
- - 涉及改稿时,优先给“可直接应用”的修改结果(通过工具写入完成),必要时补充原因。`,
- onBuildWelcome: () => {
- return {
- welcomeMessage: '你好!欢迎使用梦鱼的写作助手。可以与我讨论写作灵感、写作计划、交代我写作任务等。',
- welcomeActions: [
- '为我生成一个写作计划',
- '为我总结一下这篇笔记主要内容',
- '帮我修正这篇笔记的语法错误',
- ],
- }
- },
- onInitTools: (toolsManager) => {
-
- },
- }
- });
- const {
- intoSelectMode,
- exitSelectMode,
- selectedCount,
- isSelectMode,
- } = useChatSelection();
- onMounted(() => {
- interfaceManager.scrollToBottom?.();
- });
- </script>
|