MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / startNewAIChat

Function startNewAIChat

src/stores/aiChat.ts:603–629  ·  view source on GitHub ↗
(chatKey: string, welcomeMessage?: string)

Source from the content-addressed store, hash-verified

601 }
602
603 function startNewAIChat(chatKey: string, welcomeMessage?: string): boolean {
604 const state = getSessionState(chatKey)
605 if (!state || state.isAIThinking) return false
606
607 const draftBuffer = createAIChatBuffer(state.selectedAssistantId)
608 state.aiChatBuffers[DRAFT_AI_CHAT_KEY] = draftBuffer
609 bindDisplayedBuffer(state, DRAFT_AI_CHAT_KEY)
610 state.currentToolStatus = null
611 state.toolsUsedInCurrentRound = []
612 state.isLoadingSource = false
613 state.sessionTokenUsage = createEmptyTokenUsage()
614 state.agentStatus = null
615 state.isAborted = false
616 state.currentRequestId = ''
617 state.currentAgentRequestId = ''
618
619 if (welcomeMessage) {
620 draftBuffer.messages.push({
621 id: generateId('welcome'),
622 role: 'assistant',
623 content: welcomeMessage,
624 timestamp: Date.now(),
625 })
626 }
627
628 return true
629 }
630
631 async function loadMoreSourceMessages(): Promise<void> {
632 // Agent 模式下暂不支持加载更多

Callers 1

resetToSelectorOnEnterFunction · 0.85

Calls 6

getSessionStateFunction · 0.85
createAIChatBufferFunction · 0.85
bindDisplayedBufferFunction · 0.85
createEmptyTokenUsageFunction · 0.85
generateIdFunction · 0.70
nowMethod · 0.45

Tested by

no test coverage detected