-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: incorrect intent checking for namespace messages #822
base: VSCODE-528-mongodb-copilot
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ export function getHistoryMessages({ | |
]; | ||
if ( | ||
responseTypesToSkip.indexOf( | ||
(historyItem.result as ChatResult)?.metadata.intent | ||
(historyItem.result as ChatResult)?.metadata?.intent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another thing I noticed - not sure if there were cases where it would have manifested, but technically |
||
) > -1 | ||
) { | ||
continue; | ||
|
@@ -50,7 +50,7 @@ export function getHistoryMessages({ | |
message += fragment.value.value; | ||
|
||
if ( | ||
(historyItem.result as ChatResult)?.metadata.intent === | ||
(historyItem.result as ChatResult)?.metadata?.intent === | ||
'askForNamespace' | ||
) { | ||
// When the message is the assistant asking for part of a namespace, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import { getHistoryMessages } from './history'; | ||
import type { ChatResult } from '../constants'; | ||
|
||
export const DB_NAME_ID = 'DATABASE_NAME'; | ||
export const COL_NAME_ID = 'COLLECTION_NAME'; | ||
|
@@ -64,20 +65,22 @@ No names found. | |
// message was to connect. We want to use the last | ||
// message they sent before the connection name as their prompt. | ||
let userPrompt = request.prompt; | ||
if ( | ||
connectionNames.includes(request.prompt) && | ||
(context.history[context.history.length - 1] as vscode.ChatResponseTurn) | ||
?.result?.metadata?.askToConnect | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where the bug was - |
||
) { | ||
// Go through the history in reverse order to find the last user message. | ||
for (let i = historyMessages.length - 1; i >= 0; i--) { | ||
if ( | ||
historyMessages[i].role === vscode.LanguageModelChatMessageRole.User | ||
) { | ||
userPrompt = historyMessages[i].content; | ||
// Remove the item from the history messages array. | ||
historyMessages = historyMessages.slice(0, i); | ||
break; | ||
if (connectionNames.includes(request.prompt)) { | ||
const previousResponse = context.history[ | ||
context.history.length - 1 | ||
] as vscode.ChatResponseTurn; | ||
const intent = (previousResponse?.result as ChatResult).metadata.intent; | ||
if (intent === 'askToConnect') { | ||
// Go through the history in reverse order to find the last user message. | ||
for (let i = historyMessages.length - 1; i >= 0; i--) { | ||
if ( | ||
historyMessages[i].role === vscode.LanguageModelChatMessageRole.User | ||
) { | ||
userPrompt = historyMessages[i].content; | ||
// Remove the item from the history messages array. | ||
historyMessages = historyMessages.slice(0, i); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change allows the debugger to bind breakpoints we put in the typescript files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! Nice add.