Skip to content

feat: application assess #3312

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

Merged
merged 1 commit into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/application/serializers/application_access_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class AccessTokenEditSerializer(serializers.Serializer):
label=_("Whitelist")),
show_source = serializers.BooleanField(required=False,
label=_("Whether to display knowledge sources"))
show_exec = serializers.BooleanField(required=False,
label=_("Display execution details"))
language = serializers.CharField(required=False, allow_blank=True, allow_null=True,
label=_("language"))
authentication = serializers.BooleanField(default=False, label="Do you need authentication")
Expand Down Expand Up @@ -60,6 +62,8 @@ def edit(self, instance):
application_access_token.white_list = instance.get('white_list')
if 'show_source' in instance and instance.get('show_source') is not None:
application_access_token.show_source = instance.get('show_source')
if 'show_exec' in instance and instance.get('show_exec') is not None:
application_access_token.show_exec = instance.get('show_exec')
if 'language' in instance and instance.get('language') is not None:
application_access_token.language = instance.get('language')
if 'language' not in instance or instance.get('language') is None:
Expand Down
14 changes: 13 additions & 1 deletion apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8348,4 +8348,16 @@ msgid "Update appearance settings"
msgstr ""

msgid "Application Access"
msgstr ""
msgstr ""

msgid "Display execution details"
msgstr ""

msgid "LOCAL"
msgstr "Account login"

msgid "CAS"
msgstr "CAS"

msgid "LDAP"
msgstr "LDAP"
14 changes: 13 additions & 1 deletion apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8474,4 +8474,16 @@ msgid "Update appearance settings"
msgstr "更新外观设置"

msgid "Application Access"
msgstr "应用接入"
msgstr "应用接入"

msgid "Display execution details"
msgstr "是否显示执行详情"

msgid "LOCAL"
msgstr "账号登录"

msgid "CAS"
msgstr "CAS"

msgid "LDAP"
msgstr "LDAP"
14 changes: 13 additions & 1 deletion apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8474,4 +8474,16 @@ msgid "Update appearance settings"
msgstr "更新外觀設置"

msgid "Application Access"
msgstr "應用介入"
msgstr "應用介入"

msgid "Display execution details"
msgstr "是否顯示執行詳情"

msgid "LOCAL"
msgstr "帳號登入"

msgid "CAS"
msgstr "CAS"

msgid "LDAP"
msgstr "LDAP"
23 changes: 22 additions & 1 deletion ui/src/api/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ const getAccessToken: (application_id: string, loading?: Ref<boolean>) => Promis
) => {
return get(`${prefix.value}/${application_id}/access_token`, undefined, loading)
}
/**
* 获取应用设置
* @param application_id 应用id
* @param loading 加载器
* @returns
*/
const getApplicationSetting: (
application_id: string,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (application_id, loading) => {
return get(`${prefix.value}/${application_id}/setting`, undefined, loading)
}

/**
* 修改AccessToken
Expand Down Expand Up @@ -167,7 +179,14 @@ const open: (application_id: string, loading?: Ref<boolean>) => Promise<Result<s
const chat: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
return postStream(`/api/chat_message/${chat_id}`, data)
}

/**
* 获取对话用户认证类型
* @param loading 加载器
* @returns
*/
const getChatUserAuthType: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
return get(`/chat_user/auth/types`, {}, loading)
}
export default {
getAllApplication,
getApplication,
Expand All @@ -182,4 +201,6 @@ export default {
getStatistics,
open,
chat,
getChatUserAuthType,
getApplicationSetting,
}
8 changes: 7 additions & 1 deletion ui/src/views/application-overview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,13 @@ function openDisplaySettingDialog() {
currentDisplaySettingDialog.value = DisplaySettingDialog
}
nextTick(() => {
DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
if (currentDisplaySettingDialog.value == XPackDisplaySettingDialog) {
applicationApi.getApplicationSetting(id).then((ok) => {
DisplaySettingDialogRef.value?.open(ok.data, detail.value)
})
} else {
DisplaySettingDialogRef.value?.open(accessToken.value, detail.value)
}
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@
<el-form-item :label="$t('views.applicationOverview.appInfo.LimitDialog.authentication')">
<el-switch size="small" v-model="form.authentication" @change="firstGeneration"></el-switch>
</el-form-item>
<el-radio-group v-if="form.authentication" v-model="form.method" class="card__radio">
<el-card shadow="never" class="mb-16" :class="form.method === 'replace' ? 'active' : ''">
<el-radio-group
v-if="form.authentication"
v-model="form.authentication_value.type"
class="card__radio"
>
<el-card
shadow="never"
class="mb-16"
:class="form.authentication_value.type === 'password' ? 'active' : ''"
>
<el-radio value="replace" size="large">
<p class="mb-4 lighter">
{{ $t('views.applicationOverview.appInfo.LimitDialog.authenticationValue') }}
Expand All @@ -40,7 +48,7 @@
<el-form-item class="ml-24">
<el-input
class="authentication-append-input"
v-model="form.authentication_value"
v-model="form.authentication_value.password_value"
readonly
style="width: 268px"
>
Expand Down Expand Up @@ -69,9 +77,12 @@
</el-input>
</el-form-item>
</el-card>

<el-card shadow="never" class="mb-16" :class="form.method === 'complete' ? 'active' : ''">
<el-radio value="complete" size="large">
<el-card
shadow="never"
class="mb-16"
:class="form.authentication_value.type === 'login' ? 'active' : ''"
>
<el-radio value="login" size="large">
<p class="mb-16 lighter">
{{ $t('views.system.authentication.title') }}
<el-button type="primary" link @click="router.push({ path: '' })">
Expand All @@ -88,18 +99,14 @@
trigger: 'change',
},
]"
prop="checkList"
prop="authentication_value.login_value"
class="ml-24 border-t"
style="padding-top: 16px"
>
<el-checkbox-group v-model="form.checkList">
<el-checkbox label="账号登录" value="账号登录" />
<el-checkbox label="LDAP" value="LDAP" />
<el-checkbox label="OIDC" value="OIDC" />
<el-checkbox label="CAS" value="CAS" />
<el-checkbox label="企业微信" value="企业微信" />
<el-checkbox label="钉钉" value="钉钉" />
<el-checkbox label="飞书" value="飞书" />
<el-checkbox-group v-model="form.authentication_value.login_value">
<template v-for="t in auth_list" :key="t.value">
<el-checkbox :label="t.label" :value="t.value" />
</template>
</el-checkbox-group>
</el-form-item>
</el-card>
Expand Down Expand Up @@ -146,13 +153,13 @@ const {
} = route

const emit = defineEmits(['refresh'])

const auth_list = ref<Array<{ label: string; value: string }>>([])
const limitFormRef = ref()
const form = ref<any>({
access_num: 0,
white_active: true,
white_list: '',
authentication_value: '',
authentication_value: {},
authentication: false,
})

Expand All @@ -168,14 +175,26 @@ watch(dialogVisible, (bool) => {
}
}
})

watch(
() => form.authentication,
(b) => {
if (b) {
applicationApi.getChatUserAuthType().then((ok) => {
auth_list.value = ok.data
})
}
},
)
const open = (data: any) => {
form.value.access_num = data.access_num
form.value.white_active = data.white_active
form.value.white_list = data.white_list?.length ? data.white_list?.join('\n') : ''
form.value.authentication_value = data.authentication_value
form.value.authentication = data.authentication
dialogVisible.value = true
applicationApi.getChatUserAuthType().then((ok) => {
auth_list.value = ok.data
})
}

const submit = async (formEl: FormInstance | undefined) => {
Expand Down Expand Up @@ -207,7 +226,7 @@ function generateAuthenticationValue(length: number = 10) {
.join('')
}
function refreshAuthentication() {
form.value.authentication_value = generateAuthenticationValue()
form.value.authentication_value.password_value = generateAuthenticationValue()
}

function firstGeneration() {
Expand Down
Loading