Открыть боковую панель
code
vscode
Коммиты
8243aa99
Не подтверждена
Коммит
8243aa99
создал
Апр 03, 2025
по автору
Benjamin Pasero
Зафиксировано автором
GitHub
Апр 03, 2025
Просмотр файлов
chat - make request forwarding fail in case of recursion (#245415)
владелец
3561b4e9
Изменения
1
Скрыть пробелы
Построчно
Рядом
src/vs/workbench/contrib/chat/browser/chatSetup.ts
Просмотр файла @
8243aa99
...
...
@@ -230,21 +230,32 @@ class SetupChatAgentImplementation extends Disposable implements IChatAgentImple
}
private
async
forwardRequestToCopilot
(
requestModel
:
IChatRequestModel
,
progress
:
(
part
:
IChatProgress
)
=>
void
,
chatService
:
IChatService
,
languageModelsService
:
ILanguageModelsService
,
chatAgentService
:
IChatAgentService
,
chatWidgetService
:
IChatWidgetService
):
Promise
<
void
>
{
if
(
this
.
pendingForwardedRequests
.
has
(
requestModel
.
id
))
{
return
this
.
pendingForwardedRequests
.
get
(
requestModel
.
id
)
!
;
try
{
await
this
.
doForwardRequestToCopilot
(
requestModel
,
progress
,
chatService
,
languageModelsService
,
chatAgentService
,
chatWidgetService
);
}
catch
(
error
)
{
progress
({
kind
:
'
warning
'
,
content
:
new
MarkdownString
(
localize
(
'
copilotUnavailableWarning
'
,
"
Copilot failed to get a response. Please try again.
"
))
});
}
}
const
forwardRequest
=
this
.
doForwardRequestToCopilot
(
requestModel
,
progress
,
chatService
,
languageModelsService
,
chatAgentService
,
chatWidgetService
);
this
.
pendingForwardedRequests
.
set
(
requestModel
.
id
,
forwardRequest
);
private
async
doForwardRequestToCopilot
(
requestModel
:
IChatRequestModel
,
progress
:
(
part
:
IChatProgress
)
=>
void
,
chatService
:
IChatService
,
languageModelsService
:
ILanguageModelsService
,
chatAgentService
:
IChatAgentService
,
chatWidgetService
:
IChatWidgetService
):
Promise
<
void
>
{
if
(
this
.
pendingForwardedRequests
.
has
(
requestModel
.
session
.
sessionId
))
{
throw
new
Error
(
'
Request already in progress
'
);
}
const
forwardRequest
=
this
.
doForwardRequestToCopilotWhenReady
(
requestModel
,
progress
,
chatService
,
languageModelsService
,
chatAgentService
,
chatWidgetService
);
this
.
pendingForwardedRequests
.
set
(
requestModel
.
session
.
sessionId
,
forwardRequest
);
try
{
await
forwardRequest
;
}
finally
{
this
.
pendingForwardedRequests
.
delete
(
requestModel
.
i
d
);
this
.
pendingForwardedRequests
.
delete
(
requestModel
.
session
.
sessionI
d
);
}
}
private
async
doForwardRequestToCopilot
(
requestModel
:
IChatRequestModel
,
progress
:
(
part
:
IChatProgress
)
=>
void
,
chatService
:
IChatService
,
languageModelsService
:
ILanguageModelsService
,
chatAgentService
:
IChatAgentService
,
chatWidgetService
:
IChatWidgetService
):
Promise
<
void
>
{
private
async
doForwardRequestToCopilot
WhenReady
(
requestModel
:
IChatRequestModel
,
progress
:
(
part
:
IChatProgress
)
=>
void
,
chatService
:
IChatService
,
languageModelsService
:
ILanguageModelsService
,
chatAgentService
:
IChatAgentService
,
chatWidgetService
:
IChatWidgetService
):
Promise
<
void
>
{
// We need a signal to know when we can resend the request to
// Copilot. Waiting for the registration of the agent is not
...
...
@@ -288,7 +299,7 @@ class SetupChatAgentImplementation extends Disposable implements IChatAgentImple
}
const
widget
=
chatWidgetService
.
getWidgetBySessionId
(
requestModel
.
session
.
sessionId
);
chatService
.
resendRequest
(
requestModel
,
{
await
chatService
.
resendRequest
(
requestModel
,
{
mode
:
widget
?.
input
.
currentMode
,
userSelectedModelId
:
widget
?.
input
.
currentLanguageModel
,
});
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать