fix: 修复导出应用日志引用分段字段格式

This commit is contained in:
shaohuzhang1 2024-10-29 17:29:19 +08:00 committed by shaohuzhang1
parent 67fd113449
commit e68e5873c9
10 changed files with 23 additions and 25 deletions

View File

@ -716,6 +716,7 @@ class ApplicationSerializer(serializers.Serializer):
application.save() application.save()
# 插入知识库关联关系 # 插入知识库关联关系
self.save_application_mapping(application_dataset_id_list, dataset_id_list, application.id) self.save_application_mapping(application_dataset_id_list, dataset_id_list, application.id)
chat_cache.clear_by_application_id(str(application.id))
work_flow_version = WorkFlowVersion(work_flow=work_flow, application=application, work_flow_version = WorkFlowVersion(work_flow=work_flow, application=application,
name=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), name=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
publish_user_id=user_id, publish_user_id=user_id,

View File

@ -167,25 +167,35 @@ class ChatSerializers(serializers.Serializer):
os.path.join(PROJECT_DIR, "apps", "application", 'sql', 'list_application_chat.sql')), os.path.join(PROJECT_DIR, "apps", "application", 'sql', 'list_application_chat.sql')),
with_table_name=False) with_table_name=False)
@staticmethod
def paragraph_list_to_string(paragraph_list):
return "\n**********\n".join(
[f"{paragraph.get('title')}:\n{paragraph.get('content')}" for paragraph in paragraph_list])
@staticmethod @staticmethod
def to_row(row: Dict): def to_row(row: Dict):
details = row.get('details') details = row.get('details')
padding_problem_text = details.get('problem_padding').get( padding_problem_text = details.get('problem_padding').get(
'padding_problem_text') if 'problem_padding' in details and 'padding_problem_text' in details.get( 'padding_problem_text') if 'problem_padding' in details and 'padding_problem_text' in details.get(
'problem_padding') else "" 'problem_padding') else ""
paragraph_list = details.get('search_step').get( search_dataset_node_list = [(key, node) for key, node in details.items() if
'paragraph_list') if 'search_step' in details and 'paragraph_list' in details.get('search_step') else [] node.get("type") == 'search-dataset-node' or node.get(
for key, node in details.items(): "step_type") == 'search_step']
if node.get('type') == 'search-dataset-node' and node.get('paragraph_list') is not None and len( reference_paragraph_len = '\n'.join([str(len(node.get('paragraph_list',
node.get('paragraph_list')) > 0: []))) if key == 'search_step' else node.get(
paragraph_list = node.get('paragraph_list') 'name') + ':' + str(len(node.get('paragraph_list', []))) for
key, node in search_dataset_node_list])
reference_paragraph = '\n----------\n'.join(
[ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list',
[])) if key == 'search_step' else node.get(
'name') + ':\n' + ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list',
[])) for
key, node in search_dataset_node_list])
improve_paragraph_list = row.get('improve_paragraph_list') improve_paragraph_list = row.get('improve_paragraph_list')
vote_status_map = {'-1': '未投票', '0': '赞同', '1': '反对'} vote_status_map = {'-1': '未投票', '0': '赞同', '1': '反对'}
return [str(row.get('chat_id')), row.get('abstract'), row.get('problem_text'), padding_problem_text, return [str(row.get('chat_id')), row.get('abstract'), row.get('problem_text'), padding_problem_text,
row.get('answer_text'), vote_status_map.get(row.get('vote_status')), len(paragraph_list), "\n".join( row.get('answer_text'), vote_status_map.get(row.get('vote_status')), reference_paragraph_len,
[f"{index}{paragraph_list[index].get('title')}\n{paragraph_list[index].get('content')}" for index reference_paragraph,
in
range(len(paragraph_list))]),
"\n".join([ "\n".join([
f"{improve_paragraph_list[index].get('title')}\n{improve_paragraph_list[index].get('content')}" f"{improve_paragraph_list[index].get('title')}\n{improve_paragraph_list[index].get('content')}"
for index in range(len(improve_paragraph_list))]), for index in range(len(improve_paragraph_list))]),

View File

@ -46,15 +46,10 @@ const form_data = ref({})
const item = ref({}) const item = ref({})
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>() const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
const validate = () => { const validate = () => {
console.log('asda')
dynamicsFormRef.value dynamicsFormRef.value
?.validate() ?.validate()
.then((ok) => { .then((ok) => {})
console.log('ok') .catch((e) => {})
})
.catch((e) => {
console.log(e)
})
} }
</script> </script>
<style lang="scss"></style> <style lang="scss"></style>

View File

@ -80,7 +80,6 @@ const split_md_img = (result: Array<string>) => {
const split_md_img_ = (source: string) => { const split_md_img_ = (source: string) => {
const temp_md_img_list = source.match(/(!\[.*?\]\(.*?\){.*?})|(!\[.*?\]\(.*?\))/g) const temp_md_img_list = source.match(/(!\[.*?\]\(.*?\){.*?})|(!\[.*?\]\(.*?\))/g)
console.log(temp_md_img_list)
const md_img_list = temp_md_img_list ? temp_md_img_list.filter((i) => i) : [] const md_img_list = temp_md_img_list ? temp_md_img_list.filter((i) => i) : []
const split_img_value = source const split_img_value = source
.split(/(!\[.*?\]\(.*?\){.*?})|(!\[.*?\]\(.*?\))/g) .split(/(!\[.*?\]\(.*?\){.*?})|(!\[.*?\]\(.*?\))/g)

View File

@ -79,7 +79,6 @@ const writeValue = ref('')
const loading = ref(false) const loading = ref(false)
watch(isEdit, (bool) => { watch(isEdit, (bool) => {
console.log(bool)
if (!bool) { if (!bool) {
writeValue.value = '' writeValue.value = ''
emit('close') emit('close')

View File

@ -102,7 +102,6 @@ watch(debugVisible, (bool) => {
}) })
const submit = async (formEl: FormInstance | undefined) => { const submit = async (formEl: FormInstance | undefined) => {
console.log(formEl)
const validate = formEl ? formEl.validate() : Promise.resolve() const validate = formEl ? formEl.validate() : Promise.resolve()
validate.then(() => { validate.then(() => {
functionLibApi.postFunctionLibDebug(form.value, loading).then((res) => { functionLibApi.postFunctionLibDebug(form.value, loading).then((res) => {

View File

@ -87,7 +87,6 @@ const initActive = async () => {
appSecret: props.config.app_secret, appSecret: props.config.app_secret,
agent_id: props.config.agent_id agent_id: props.config.agent_id
} }
console.log(props.config)
const redirectUri = encodeURIComponent(window.location.origin) const redirectUri = encodeURIComponent(window.location.origin)

View File

@ -46,7 +46,6 @@ const init = async () => {
}, },
onCheckWeComLogin: obj.value, onCheckWeComLogin: obj.value,
async onLoginSuccess({ code }: any) { async onLoginSuccess({ code }: any) {
console.log('Login success:', code)
user.wecomCallback(code).then(() => { user.wecomCallback(code).then(() => {
setTimeout(() => { setTimeout(() => {
router.push({ name: 'home' }) router.push({ name: 'home' })

View File

@ -43,7 +43,6 @@ const currentIndex = ref(null)
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
const open = (row: any, index: any) => { const open = (row: any, index: any) => {
// console.log(row, index)
if (row) { if (row) {
currentItem.value = cloneDeep(row) currentItem.value = cloneDeep(row)
currentIndex.value = index currentIndex.value = index

View File

@ -107,7 +107,6 @@ function deleteParam(index: any) {
} }
function refresh(data: any, index: any) { function refresh(data: any, index: any) {
// console.log(data, index)
for (let i = 0; i < modelParamsForm.value.length; i++) { for (let i = 0; i < modelParamsForm.value.length; i++) {
let field = modelParamsForm.value[i].field let field = modelParamsForm.value[i].field
let label = modelParamsForm.value[i].label let label = modelParamsForm.value[i].label
@ -136,7 +135,6 @@ function refresh(data: any, index: any) {
} }
function submit() { function submit() {
// console.log('submit: ', modelParamsForm.value)
ModelApi.updateModelParamsForm(props.model.id, modelParamsForm.value, loading).then((ok) => { ModelApi.updateModelParamsForm(props.model.id, modelParamsForm.value, loading).then((ok) => {
MsgSuccess('模型参数保存成功') MsgSuccess('模型参数保存成功')
close() close()