Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
d2028bf6
提交
d2028bf6
编辑于
1 year ago
作者:
Jannik Lehmann
提交者:
Lukas 'ai-pi' Eipert
1 year ago
浏览文件
操作
下载
补丁
差异文件
Refactor DuoChat Feedback message handling
This commit refactors the DuoChat Feedback message handling EE: true
上级
44a5033a
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue
+25
-1
25 个添加, 1 个删除
ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue
ee/spec/frontend/ai/tanuki_bot/components/app_spec.js
+46
-0
46 个添加, 0 个删除
ee/spec/frontend/ai/tanuki_bot/components/app_spec.js
有
71 个添加
和
1 个删除
ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue
+
25
−
1
浏览文件 @
d2028bf6
...
@@ -11,6 +11,7 @@ import aiResponseSubscription from 'ee/graphql_shared/subscriptions/ai_completio
...
@@ -11,6 +11,7 @@ import aiResponseSubscription from 'ee/graphql_shared/subscriptions/ai_completio
import
DuoChatCallout
from
'
ee/ai/components/global_callout/duo_chat_callout.vue
'
;
import
DuoChatCallout
from
'
ee/ai/components/global_callout/duo_chat_callout.vue
'
;
import
getAiMessages
from
'
ee/ai/graphql/get_ai_messages.query.graphql
'
;
import
getAiMessages
from
'
ee/ai/graphql/get_ai_messages.query.graphql
'
;
import
chatMutation
from
'
ee/ai/graphql/chat.mutation.graphql
'
;
import
chatMutation
from
'
ee/ai/graphql/chat.mutation.graphql
'
;
import
duoUserFeedbackMutation
from
'
ee/ai/graphql/duo_user_feedback.mutation.graphql
'
;
import
Tracking
from
'
~/tracking
'
;
import
Tracking
from
'
~/tracking
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
{
i18n
,
GENIE_CHAT_RESET_MESSAGE
,
GENIE_CHAT_CLEAN_MESSAGE
}
from
'
ee/ai/constants
'
;
import
{
i18n
,
GENIE_CHAT_RESET_MESSAGE
,
GENIE_CHAT_CLEAN_MESSAGE
}
from
'
ee/ai/constants
'
;
...
@@ -162,7 +163,7 @@ export default {
...
@@ -162,7 +163,7 @@ export default {
onCalloutDismissed
()
{
onCalloutDismissed
()
{
this
.
helpCenterState
.
showTanukiBotChatDrawer
=
true
;
this
.
helpCenterState
.
showTanukiBotChatDrawer
=
true
;
},
},
onTrackFeedback
({
feedbackChoices
,
didWhat
,
improveWhat
}
=
{})
{
onTrackFeedback
({
feedbackChoices
,
didWhat
,
improveWhat
,
message
}
=
{})
{
this
.
track
(
TANUKI_BOT_TRACKING_EVENT_NAME
,
{
this
.
track
(
TANUKI_BOT_TRACKING_EVENT_NAME
,
{
action
:
'
click_button
'
,
action
:
'
click_button
'
,
label
:
'
response_feedback
'
,
label
:
'
response_feedback
'
,
...
@@ -173,6 +174,29 @@ export default {
...
@@ -173,6 +174,29 @@ export default {
prompt_location
:
'
after_content
'
,
prompt_location
:
'
after_content
'
,
},
},
});
});
if
(
message
)
{
const
{
id
,
requestId
,
extras
,
role
,
content
}
=
message
;
this
.
$apollo
.
mutate
({
mutation
:
duoUserFeedbackMutation
,
variables
:
{
input
:
{
aiMessageId
:
id
,
},
},
})
.
catch
(()
=>
{
// silent failure because of fire and forget
});
this
.
addDuoChatMessage
({
requestId
,
role
,
content
,
extras
:
{
...
extras
,
hasFeedback
:
true
},
});
}
},
},
},
},
};
};
...
...
此差异已折叠。
点击以展开。
ee/spec/frontend/ai/tanuki_bot/components/app_spec.js
+
46
−
0
浏览文件 @
d2028bf6
...
@@ -10,6 +10,7 @@ import { GENIE_CHAT_RESET_MESSAGE, GENIE_CHAT_CLEAN_MESSAGE } from 'ee/ai/consta
...
@@ -10,6 +10,7 @@ import { GENIE_CHAT_RESET_MESSAGE, GENIE_CHAT_CLEAN_MESSAGE } from 'ee/ai/consta
import
{
TANUKI_BOT_TRACKING_EVENT_NAME
}
from
'
ee/ai/tanuki_bot/constants
'
;
import
{
TANUKI_BOT_TRACKING_EVENT_NAME
}
from
'
ee/ai/tanuki_bot/constants
'
;
import
aiResponseSubscription
from
'
ee/graphql_shared/subscriptions/ai_completion_response.subscription.graphql
'
;
import
aiResponseSubscription
from
'
ee/graphql_shared/subscriptions/ai_completion_response.subscription.graphql
'
;
import
chatMutation
from
'
ee/ai/graphql/chat.mutation.graphql
'
;
import
chatMutation
from
'
ee/ai/graphql/chat.mutation.graphql
'
;
import
duoUserFeedbackMutation
from
'
ee/ai/graphql/duo_user_feedback.mutation.graphql
'
;
import
getAiMessages
from
'
ee/ai/graphql/get_ai_messages.query.graphql
'
;
import
getAiMessages
from
'
ee/ai/graphql/get_ai_messages.query.graphql
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
...
@@ -43,8 +44,24 @@ describe('GitLab Duo Chat', () => {
...
@@ -43,8 +44,24 @@ describe('GitLab Duo Chat', () => {
const
subscriptionHandlerMock
=
jest
.
fn
().
mockResolvedValue
(
MOCK_TANUKI_SUCCESS_RES
);
const
subscriptionHandlerMock
=
jest
.
fn
().
mockResolvedValue
(
MOCK_TANUKI_SUCCESS_RES
);
const
chatMutationHandlerMock
=
jest
.
fn
().
mockResolvedValue
(
MOCK_TANUKI_BOT_MUTATATION_RES
);
const
chatMutationHandlerMock
=
jest
.
fn
().
mockResolvedValue
(
MOCK_TANUKI_BOT_MUTATATION_RES
);
const
duoUserFeedbackMutationHandlerMock
=
jest
.
fn
().
mockResolvedValue
({});
const
queryHandlerMock
=
jest
.
fn
().
mockResolvedValue
(
MOCK_CHAT_CACHED_MESSAGES_RES
);
const
queryHandlerMock
=
jest
.
fn
().
mockResolvedValue
(
MOCK_CHAT_CACHED_MESSAGES_RES
);
const
feedbackData
=
{
feedbackChoices
:
[
'
useful
'
,
'
not_relevant
'
],
didWhat
:
'
provided clarity
'
,
improveWhat
:
'
more examples
'
,
message
:
{
requestId
:
'
1234567890
'
,
id
:
'
abcdefgh
'
,
role
:
'
user
'
,
content
:
'
test
'
,
extras
:
{
exampleExtraContent
:
1
,
},
},
};
const
findCallout
=
()
=>
wrapper
.
findComponent
(
DuoChatCallout
);
const
findCallout
=
()
=>
wrapper
.
findComponent
(
DuoChatCallout
);
const
createComponent
=
({
const
createComponent
=
({
...
@@ -62,6 +79,7 @@ describe('GitLab Duo Chat', () => {
...
@@ -62,6 +79,7 @@ describe('GitLab Duo Chat', () => {
const
apolloProvider
=
createMockApollo
([
const
apolloProvider
=
createMockApollo
([
[
aiResponseSubscription
,
subscriptionHandlerMock
],
[
aiResponseSubscription
,
subscriptionHandlerMock
],
[
chatMutation
,
chatMutationHandlerMock
],
[
chatMutation
,
chatMutationHandlerMock
],
[
duoUserFeedbackMutation
,
duoUserFeedbackMutationHandlerMock
],
[
getAiMessages
,
queryHandlerMock
],
[
getAiMessages
,
queryHandlerMock
],
]);
]);
...
@@ -295,6 +313,34 @@ describe('GitLab Duo Chat', () => {
...
@@ -295,6 +313,34 @@ describe('GitLab Duo Chat', () => {
},
},
});
});
});
});
it
(
'
calls the feedback GraphQL mutation when message is passed
'
,
async
()
=>
{
createComponent
();
findGlDuoChat
().
vm
.
$emit
(
'
track-feedback
'
,
feedbackData
);
await
waitForPromises
();
expect
(
duoUserFeedbackMutationHandlerMock
).
toHaveBeenCalledWith
({
input
:
{
aiMessageId
:
feedbackData
.
message
.
id
,
},
});
});
it
(
'
updates Vuex store correctly when message is passed
'
,
async
()
=>
{
createComponent
();
findGlDuoChat
().
vm
.
$emit
(
'
track-feedback
'
,
feedbackData
);
await
waitForPromises
();
expect
(
actionSpies
.
addDuoChatMessage
).
toHaveBeenCalledWith
(
expect
.
any
(
Object
),
expect
.
objectContaining
({
requestId
:
feedbackData
.
message
.
requestId
,
role
:
feedbackData
.
message
.
role
,
content
:
feedbackData
.
message
.
content
,
extras
:
{
...
feedbackData
.
message
.
extras
,
hasFeedback
:
true
},
}),
);
});
});
});
});
});
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录