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
|
1. 获取API Key
|
||||||
在[Langsearch](https://langsearch.com/overview) 上申请 API 密钥。
|
在[Langsearch](https://langsearch.com/overview) 上申请 API 密钥。
|
||||||

|

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

|

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