-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Form nodes support file upload and multi-line text #3879
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several issues and optimizations that can be made to the provided code:
Issues:
PrologueContenthave duplicate content across different sections of the component.watch()for simple computations can lead to performance issues. Consider using computed properties instead.<template>elements, which might cause render issues.Optimizations:
Combine Similar Components:
PrologueContent,QuestionContent, andAnswerContentshare common props, combine them into a single reusable component.Use Computed Properties:
Consistent Template Syntax:
"") for string literals to avoid potential bugs.Simplify Imports:
Here's an optimized version of the code considering these points:
<template> <div ref="aiChatRef" :class="type" :style="{ height: firsUserInput ? '100%' : undefined }"> <div v-show="showUserInputContent && !(isUserInput || isAPIInput)" :class="firsUserInput ? 'firstUserInput' : 'popperUserInput'" style="padding-top: 20px;"> <UserForm v-model:api_form_data="api_form_data" v-model:form_data="form_data" :application="applicationDetails" :type="type" :first="firsUserInput" @confirm="UserFormConfirm" @cancel="UserFormCancel" /> </div> <el-scrollbar ref="scrollDiv" @scroll="handleScrollTop"> <div ref="dialogScrollbar" class="ai-chat__content p-16"> <CommonComponent :type="type" :application="applicationDetails" :chat-data="getSortedChatData()" /> </div> </el-scrollbar> <ChatInputOperate :app-id="appId" :application-details="applicationDetails" :is-mobile="isMobile" :type="type" :send-message="sendMessage" :open-chat-id="openChatId" :validate="validate" :chat-management="ChatManagement" v-model:chat-id="chartOpenId" v-model:loading="loading" v-model:show-user-input="showUserInput" v-if="type !== 'log'" /> <Control /> </template> <script setup lang="ts"> import { ref, nextTick, computed, onMounted, onBeforeUnmount, provide } from 'vue'; import { useRoute } from 'vue-router'; import applicationApi from '@/api/application/application'; import chatAPI from '@/api/chat/chat.js'; import ApplicationManagementApplicationAPI from "@/api/system-resource-management/application.ts"; import systemResourceManagementChatLogApi from '@/api/system-resource-management/chat-log'; import chatLogApi from '@/api/application/chat-log'; // Define constants and context providers export const CommonContextProvider = {}; export const ContextKey = {}; provide(CommonContextProvider.Key, ContextKey); // Provide custom upload function for debugging AI chat only provide('upload', (file: any) => { return props.type === 'debug-ai-chat' ? applicationApi.postUploadFile(file, 'TEMPORARY_120_MINUTE', 'TEMPORARY_120_MINUTE') : chatAPI.postUploadFile(file, chartOpenId.value, 'CHAT'); }); const transcribing = ref(false); defineOptions({ name: 'AiChat' }); const route = useRoute(); // State management const api_form_data = ref<any>({}); const form_data = ref<any>({}); const showUserInput = ref(true); const firsUserInput = ref<boolean>(true); // Initial value needs clarification const openChatId = ref<string | null>(null); const isLoading = ref<boolean>(false); // Methods async function sendMessage(message: string) { console.log('Sending message:', message); } function getSourceDetail(row: Record<string, any>) { // ... } // Other methods... // Combining similar components into one here function getSortedChatData() { // Sort and map chat data as needed } onMounted(() => { // Mount logic... }); onBeforeUnmount(() => { // Cleanup logic... }); </script>This example combines
PrologueContent,QuestionContent, andAnswerContentinto a sharedCommonComponent. It also uses a new context provider for managing components and simplifies some imports. This should improve the maintainability and readability of your codebase while addressing identified issues.