mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: User input optimization
* fix: Fix img 404 * feat: User input optimization
This commit is contained in:
parent
5eee6bfb6c
commit
378de21fa2
|
|
@ -7,7 +7,7 @@ LangSearch 是一个提供免费Web Search API和Rerank API的服务,支持新
|
|||
|
||||
1. 获取API Key
|
||||
在[Langsearch](https://langsearch.com/overview) 上申请 API 密钥。
|
||||

|
||||

|
||||
2. 在函数库中配置
|
||||
在函数库的LangSearch函数面板中,点击 … > 启用参数,填写 API 密钥,并启用该函数。
|
||||

|
||||
|
|
|
|||
|
|
@ -780,6 +780,4 @@ onMounted(() => {
|
|||
}
|
||||
}
|
||||
}
|
||||
.chat-pc {
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ import { useRoute } from 'vue-router'
|
|||
import { MsgWarning } from '@/utils/message'
|
||||
import { t } from '@/locales'
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { accessToken }
|
||||
} = route
|
||||
const props = defineProps<{
|
||||
application: any
|
||||
type: 'log' | 'ai-chat' | 'debug-ai-chat'
|
||||
|
|
@ -78,6 +81,8 @@ const inputFieldList = ref<FormField[]>([])
|
|||
const apiInputFieldList = ref<FormField[]>([])
|
||||
const inputFieldConfig = ref({ title: t('chat.userInput') })
|
||||
const showUserInput = ref(true)
|
||||
const firstMounted = ref(false)
|
||||
|
||||
const emit = defineEmits(['update:api_form_data', 'update:form_data', 'confirm', 'cancel'])
|
||||
|
||||
const api_form_data_context = computed({
|
||||
|
|
@ -100,7 +105,7 @@ const form_data_context = computed({
|
|||
|
||||
watch(
|
||||
() => props.application,
|
||||
() => {
|
||||
(data) => {
|
||||
handleInputFieldList()
|
||||
}
|
||||
)
|
||||
|
|
@ -352,15 +357,15 @@ const decodeQuery = (query: string) => {
|
|||
}
|
||||
}
|
||||
const confirmHandle = () => {
|
||||
if (checkInputParam()) {
|
||||
emit('confirm')
|
||||
}
|
||||
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(form_data_context.value))
|
||||
emit('confirm')
|
||||
}
|
||||
const cancelHandle = () => {
|
||||
emit('cancel')
|
||||
}
|
||||
defineExpose({ checkInputParam })
|
||||
onMounted(() => {
|
||||
firstMounted.value = true
|
||||
handleInputFieldList()
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -196,13 +196,27 @@ const toggleUserInput = () => {
|
|||
}
|
||||
|
||||
function UserFormConfirm() {
|
||||
firsUserInput.value = false
|
||||
showUserInput.value = false
|
||||
if (userFormRef.value?.checkInputParam()) {
|
||||
firsUserInput.value = false
|
||||
showUserInput.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function sendMessage(val: string, other_params_data?: any, chat?: chatType) {
|
||||
if (!userFormRef.value?.checkInputParam()) {
|
||||
if (isUserInput.value) {
|
||||
showUserInput.value = true
|
||||
}
|
||||
return
|
||||
} else {
|
||||
let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
|
||||
const newData = Object.keys(form_data.value).reduce((result: any, key: string) => {
|
||||
result[key] = Object.prototype.hasOwnProperty.call(userFormData, key)
|
||||
? userFormData[key]
|
||||
: form_data.value[key]
|
||||
return result
|
||||
}, {})
|
||||
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData))
|
||||
}
|
||||
if (!loading.value && props.applicationDetails?.name) {
|
||||
handleDebounceClick(val, other_params_data, chat)
|
||||
|
|
@ -505,6 +519,10 @@ const handleScroll = () => {
|
|||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (isUserInput.value && localStorage.getItem(`${accessToken}userForm`)) {
|
||||
let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
|
||||
form_data.value = userFormData
|
||||
}
|
||||
window.speechSynthesis.cancel()
|
||||
window.sendMessage = sendMessage
|
||||
bus.on('on:transcribing', (status: boolean) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
<template>
|
||||
<div class="function-lib-list-container p-24" style="padding-top: 16px">
|
||||
<el-tabs v-model="functionType" @tab-change="selectUserId = ''">
|
||||
<el-tabs
|
||||
v-model="functionType"
|
||||
@tab-change="
|
||||
tabChangeHandle
|
||||
|
||||
"
|
||||
>
|
||||
<el-tab-pane :label="$t('views.functionLib.title')" name="PUBLIC"></el-tab-pane>
|
||||
<el-tab-pane :label="$t('views.functionLib.internalTitle')" name="INTERNAL"></el-tab-pane>
|
||||
</el-tabs>
|
||||
|
|
@ -280,11 +286,6 @@ import { isAppIcon } from '@/utils/application'
|
|||
import InfiniteScroll from '@/components/infinite-scroll/index.vue'
|
||||
import CardBox from '@/components/card-box/index.vue'
|
||||
import AddInternalFunctionDialog from '@/views/function-lib/component/AddInternalFunctionDialog.vue'
|
||||
// const internalDesc: Record<string, any> = import.meta.glob('/fx/*/detail.md', {
|
||||
// eager: true,
|
||||
// as: 'raw'
|
||||
// })
|
||||
// console.log(internalDesc)
|
||||
|
||||
const { user } = useStore()
|
||||
|
||||
|
|
@ -331,6 +332,11 @@ watch(
|
|||
{ immediate: true }
|
||||
)
|
||||
|
||||
function tabChangeHandle() {
|
||||
selectUserId.value = 'all'
|
||||
searchValue.value = ''
|
||||
}
|
||||
|
||||
const canEdit = (row: any) => {
|
||||
return user.userInfo?.id === row?.user_id
|
||||
}
|
||||
|
|
@ -404,10 +410,12 @@ async function changeState(bool: Boolean, row: any) {
|
|||
})
|
||||
} else {
|
||||
const res = await functionLibApi.getFunctionLibById(row.id, changeStateloading)
|
||||
if (!res.data.init_params &&
|
||||
if (
|
||||
!res.data.init_params &&
|
||||
res.data.init_field_list &&
|
||||
res.data.init_field_list.length > 0 &&
|
||||
res.data.init_field_list.filter((item: any) => item.default_value).length !== res.data.init_field_list.length
|
||||
res.data.init_field_list.filter((item: any) => item.default_value).length !==
|
||||
res.data.init_field_list.length
|
||||
) {
|
||||
InitParamDrawerRef.value.open(res.data, bool)
|
||||
row.is_active = false
|
||||
|
|
|
|||
Loading…
Reference in New Issue