mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
Merge pull request #384 from voideditor/model-selection
Model selection
This commit is contained in:
commit
8a8a982d21
2 changed files with 28 additions and 9 deletions
|
|
@ -654,10 +654,12 @@ const defaultChat = {
|
||||||
submenu: MenuId.ChatTitleBarMenu,
|
submenu: MenuId.ChatTitleBarMenu,
|
||||||
title: localize('title4', "Copilot"),
|
title: localize('title4', "Copilot"),
|
||||||
icon: Codicon.copilot,
|
icon: Codicon.copilot,
|
||||||
when: ContextKeyExpr.and(
|
// Void commented this out - copilot head
|
||||||
ChatContextKeys.supported,
|
when: ContextKeyExpr.false(),
|
||||||
ContextKeyExpr.has('config.chat.commandCenter.enabled')
|
// when: ContextKeyExpr.and(
|
||||||
),
|
// ChatContextKeys.supported,
|
||||||
|
// ContextKeyExpr.has('config.chat.commandCenter.enabled')
|
||||||
|
// ),
|
||||||
order: 10001 // to the right of command center
|
order: 10001 // to the right of command center
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -667,11 +669,13 @@ MenuRegistry.appendMenuItem(MenuId.TitleBar, {
|
||||||
title: localize('title4', "Copilot"),
|
title: localize('title4', "Copilot"),
|
||||||
group: 'navigation',
|
group: 'navigation',
|
||||||
icon: Codicon.copilot,
|
icon: Codicon.copilot,
|
||||||
when: ContextKeyExpr.and(
|
when: ContextKeyExpr.false(),
|
||||||
ChatContextKeys.supported,
|
// Void commented this out - copilot head
|
||||||
ContextKeyExpr.has('config.chat.commandCenter.enabled'),
|
// when: ContextKeyExpr.and(
|
||||||
ContextKeyExpr.has('config.window.commandCenter').negate(),
|
// ChatContextKeys.supported,
|
||||||
),
|
// ContextKeyExpr.has('config.chat.commandCenter.enabled'),
|
||||||
|
// ContextKeyExpr.has('config.window.commandCenter').negate(),
|
||||||
|
// ),
|
||||||
order: 1
|
order: 1
|
||||||
}); */
|
}); */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,7 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
||||||
// above just defines helpers, below starts the actual function
|
// above just defines helpers, below starts the actual function
|
||||||
const { chatMode } = this._settingsService.state.globalSettings // should not change as we loop even if user changes it, so it goes here
|
const { chatMode } = this._settingsService.state.globalSettings // should not change as we loop even if user changes it, so it goes here
|
||||||
|
|
||||||
|
console.log('a', chatMode)
|
||||||
// clear any previous error
|
// clear any previous error
|
||||||
this._setStreamState(threadId, { error: undefined }, 'set')
|
this._setStreamState(threadId, { error: undefined }, 'set')
|
||||||
|
|
||||||
|
|
@ -669,11 +670,13 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
||||||
let isRunningWhenEnd: IsRunningType = undefined
|
let isRunningWhenEnd: IsRunningType = undefined
|
||||||
let aborted = false
|
let aborted = false
|
||||||
|
|
||||||
|
console.log('b')
|
||||||
// before enter loop, call tool
|
// before enter loop, call tool
|
||||||
if (callThisToolFirst) {
|
if (callThisToolFirst) {
|
||||||
const { interrupted } = await this._runToolCall(threadId, callThisToolFirst.name, { preapproved: true, validatedParams: callThisToolFirst.params })
|
const { interrupted } = await this._runToolCall(threadId, callThisToolFirst.name, { preapproved: true, validatedParams: callThisToolFirst.params })
|
||||||
if (interrupted) return
|
if (interrupted) return
|
||||||
}
|
}
|
||||||
|
console.log('c')
|
||||||
|
|
||||||
// tool use loop
|
// tool use loop
|
||||||
while (shouldSendAnotherMessage) {
|
while (shouldSendAnotherMessage) {
|
||||||
|
|
@ -685,14 +688,17 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
||||||
let resMessageIsDonePromise: (toolCall?: RawToolCallObj | undefined) => void // resolves when user approves this tool use (or if tool doesn't require approval)
|
let resMessageIsDonePromise: (toolCall?: RawToolCallObj | undefined) => void // resolves when user approves this tool use (or if tool doesn't require approval)
|
||||||
const messageIsDonePromise = new Promise<RawToolCallObj | undefined>((res, rej) => { resMessageIsDonePromise = res })
|
const messageIsDonePromise = new Promise<RawToolCallObj | undefined>((res, rej) => { resMessageIsDonePromise = res })
|
||||||
|
|
||||||
|
console.log('d')
|
||||||
// send llm message
|
// send llm message
|
||||||
this._setStreamState(threadId, { isRunning: 'LLM' }, 'merge')
|
this._setStreamState(threadId, { isRunning: 'LLM' }, 'merge')
|
||||||
const systemMessage = await this._generateSystemMessage(chatMode)
|
const systemMessage = await this._generateSystemMessage(chatMode)
|
||||||
|
console.log('e0')
|
||||||
const llmMessages = await this._generateLLMMessages(threadId)
|
const llmMessages = await this._generateLLMMessages(threadId)
|
||||||
const messages: LLMChatMessage[] = [
|
const messages: LLMChatMessage[] = [
|
||||||
{ role: 'system', content: systemMessage },
|
{ role: 'system', content: systemMessage },
|
||||||
...llmMessages
|
...llmMessages
|
||||||
]
|
]
|
||||||
|
console.log('e')
|
||||||
|
|
||||||
const llmCancelToken = this._llmMessageService.sendLLMMessage({
|
const llmCancelToken = this._llmMessageService.sendLLMMessage({
|
||||||
messagesType: 'chatMessages',
|
messagesType: 'chatMessages',
|
||||||
|
|
@ -734,14 +740,20 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
this._setStreamState(threadId, { streamingToken: llmCancelToken }, 'merge') // new stream token for the new message
|
this._setStreamState(threadId, { streamingToken: llmCancelToken }, 'merge') // new stream token for the new message
|
||||||
|
console.log('waiting...')
|
||||||
const toolCall = await messageIsDonePromise // wait for message to complete
|
const toolCall = await messageIsDonePromise // wait for message to complete
|
||||||
|
console.log('done!')
|
||||||
if (aborted) { return }
|
if (aborted) { return }
|
||||||
|
console.log('H')
|
||||||
this._setStreamState(threadId, { streamingToken: undefined }, 'merge') // streaming message is done
|
this._setStreamState(threadId, { streamingToken: undefined }, 'merge') // streaming message is done
|
||||||
|
console.log('I')
|
||||||
|
|
||||||
// call tool if there is one
|
// call tool if there is one
|
||||||
const tool: RawToolCallObj | undefined = toolCall
|
const tool: RawToolCallObj | undefined = toolCall
|
||||||
if (tool) {
|
if (tool) {
|
||||||
|
console.log('J')
|
||||||
const { awaitingUserApproval, interrupted } = await this._runToolCall(threadId, tool.name, { preapproved: false, unvalidatedToolParams: tool.rawParams })
|
const { awaitingUserApproval, interrupted } = await this._runToolCall(threadId, tool.name, { preapproved: false, unvalidatedToolParams: tool.rawParams })
|
||||||
|
console.log('K')
|
||||||
|
|
||||||
// stop if interrupted. we don't have to do this for llmMessage because we have a stream token for it and onAbort gets called, but we don't have the equivalent for tools.
|
// stop if interrupted. we don't have to do this for llmMessage because we have a stream token for it and onAbort gets called, but we don't have the equivalent for tools.
|
||||||
// just detect tool interruption which is the same as chat interruption right now
|
// just detect tool interruption which is the same as chat interruption right now
|
||||||
|
|
@ -756,14 +768,17 @@ class ChatThreadService extends Disposable implements IChatThreadService {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end while
|
} // end while
|
||||||
|
console.log('L')
|
||||||
|
|
||||||
|
|
||||||
// if awaiting user approval, keep isRunning true, else end isRunning
|
// if awaiting user approval, keep isRunning true, else end isRunning
|
||||||
this._setStreamState(threadId, { isRunning: isRunningWhenEnd }, 'merge')
|
this._setStreamState(threadId, { isRunning: isRunningWhenEnd }, 'merge')
|
||||||
|
console.log('M')
|
||||||
|
|
||||||
// add checkpoint before the next user message
|
// add checkpoint before the next user message
|
||||||
if (!isRunningWhenEnd)
|
if (!isRunningWhenEnd)
|
||||||
this._addUserCheckpoint({ threadId })
|
this._addUserCheckpoint({ threadId })
|
||||||
|
console.log('N')
|
||||||
|
|
||||||
// capture number of messages sent
|
// capture number of messages sent
|
||||||
this._metricsService.capture('Agent Loop Done', { nMessagesSent, chatMode })
|
this._metricsService.capture('Agent Loop Done', { nMessagesSent, chatMode })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue