Global variables support external variable; Extract module support default value (#921)

This commit is contained in:
Archer
2024-03-05 14:13:22 +08:00
committed by GitHub
parent 42a8184ea0
commit af581bc903
30 changed files with 306 additions and 200 deletions

View File

@@ -30,24 +30,29 @@ import { MongoOutLink } from '@fastgpt/service/support/outLink/schema';
import { OutLinkWithAppType } from '@fastgpt/global/support/outLink/type';
const OutLink = ({
shareId,
chatId,
showHistory,
authToken,
appName,
appIntro,
appAvatar
}: {
shareId: string;
chatId: string;
showHistory: '0' | '1';
authToken?: string;
appName?: string;
appIntro?: string;
appAvatar?: string;
}) => {
const { t } = useTranslation();
const router = useRouter();
const {
shareId = '',
chatId = '',
showHistory = '1',
authToken,
...customVariables
} = router.query as {
shareId: string;
chatId: string;
showHistory: '0' | '1';
authToken: string;
[key: string]: string;
};
const { toast } = useToast();
const { isOpen: isOpenSlider, onClose: onCloseSlider, onOpen: onOpenSlider } = useDisclosure();
const { isPc } = useSystemStore();
@@ -56,11 +61,7 @@ const OutLink = ({
const initSign = useRef(false);
const [isEmbed, setIdEmbed] = useState(true);
const {
localUId,
shareChatHistory, // abandon
clearLocalHistory // abandon
} = useShareChatStore();
const { localUId } = useShareChatStore();
const {
histories,
loadHistories,
@@ -83,7 +84,10 @@ const OutLink = ({
const { responseText, responseData } = await streamFetch({
data: {
messages: prompts,
variables,
variables: {
...customVariables,
...variables
},
shareId,
chatId: completionChatId,
outLinkUid
@@ -159,6 +163,7 @@ const OutLink = ({
},
[
chatId,
customVariables,
shareId,
outLinkUid,
t,
@@ -391,9 +396,6 @@ const OutLink = ({
export async function getServerSideProps(context: any) {
const shareId = context?.query?.shareId || '';
const chatId = context?.query?.chatId || '';
const showHistory = context?.query?.showHistory || '1';
const authToken = context?.query?.authToken || '';
const app = await (async () => {
try {
@@ -413,13 +415,9 @@ export async function getServerSideProps(context: any) {
return {
props: {
shareId,
chatId,
showHistory,
authToken,
appName: app?.appId?.name,
appAvatar: app?.appId?.avatar,
appIntro: app?.appId?.intro,
appName: app?.appId?.name || '',
appAvatar: app?.appId?.avatar || '',
appIntro: app?.appId?.intro || '',
...(await serviceSideProps(context))
}
};