* perf: some log, chatTest histories slice; http request failed tip

* fix: ssr render

* perf: if else node ui and fix value type select
This commit is contained in:
Archer
2024-05-07 15:27:05 +08:00
committed by GitHub
parent 2053bbdb1b
commit 8f9203c053
21 changed files with 164 additions and 137 deletions

View File

@@ -161,6 +161,7 @@ export const runToolWithFunctionCall = async (
const toolRunResponse = await dispatchWorkFlow({
...props,
isToolCall: true,
runtimeNodes: runtimeNodes.map((item) =>
item.nodeId === toolNode.nodeId
? {

View File

@@ -185,6 +185,7 @@ export const runToolWithPromptCall = async (
const moduleRunResponse = await dispatchWorkFlow({
...props,
isToolCall: true,
runtimeNodes: runtimeNodes.map((item) =>
item.nodeId === toolNode.nodeId
? {

View File

@@ -182,6 +182,7 @@ export const runToolWithToolChoice = async (
const toolRunResponse = await dispatchWorkFlow({
...props,
isToolCall: true,
runtimeNodes: runtimeNodes.map((item) =>
item.nodeId === toolNode.nodeId
? {

View File

@@ -8,12 +8,15 @@ export type UserChatInputProps = ModuleDispatchProps<{
}>;
export const dispatchWorkflowStart = (props: Record<string, any>) => {
const { query } = props as UserChatInputProps;
const {
query,
params: { userChatInput }
} = props as UserChatInputProps;
const { text, files } = chatValue2RuntimePrompt(query);
return {
[NodeInputKeyEnum.userChatInput]: text,
[NodeInputKeyEnum.userChatInput]: text || userChatInput,
[NodeInputKeyEnum.inputFiles]: files
};
};

View File

@@ -49,6 +49,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
variables,
node: { outputs },
histories,
isToolCall,
params: {
system_httpMethod: httpMethod = 'POST',
system_httpReqUrl: httpReqUrl,
@@ -156,17 +157,21 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
};
} catch (error) {
addLog.error('Http request error', error);
return {
[NodeOutputKeyEnum.failed]: true,
[DispatchNodeResponseKeyEnum.nodeResponse]: {
totalPoints: 0,
params: Object.keys(params).length > 0 ? params : undefined,
body: Object.keys(requestBody).length > 0 ? requestBody : undefined,
headers: Object.keys(headers).length > 0 ? headers : undefined,
httpResult: { error: formatHttpError(error) }
},
[NodeOutputKeyEnum.httpRawResponse]: getErrText(error)
};
if (isToolCall) {
return {
[NodeOutputKeyEnum.failed]: true,
[DispatchNodeResponseKeyEnum.nodeResponse]: {
totalPoints: 0,
params: Object.keys(params).length > 0 ? params : undefined,
body: Object.keys(requestBody).length > 0 ? requestBody : undefined,
headers: Object.keys(headers).length > 0 ? headers : undefined,
httpResult: { error: formatHttpError(error) }
},
[NodeOutputKeyEnum.httpRawResponse]: getErrText(error)
};
}
return Promise.reject(error);
}
};

View File

@@ -1,4 +1,4 @@
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
import { DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
import { VariableConditionEnum } from '@fastgpt/global/core/workflow/template/system/ifElse/constant';
@@ -15,6 +15,9 @@ type Props = ModuleDispatchProps<{
[NodeInputKeyEnum.condition]: IfElseConditionType;
[NodeInputKeyEnum.ifElseList]: IfElseListItemType[];
}>;
type Response = DispatchNodeResultType<{
[NodeOutputKeyEnum.ifElseResult]: string;
}>;
function checkCondition(condition: VariableConditionEnum, variableValue: any, value: string) {
const operations = {
@@ -63,7 +66,7 @@ function getResult(
return condition === 'AND' ? listResult.every(Boolean) : listResult.some(Boolean);
}
export const dispatchIfElse = async (props: Props): Promise<DispatchNodeResultType<{}>> => {
export const dispatchIfElse = async (props: Props): Promise<Response> => {
const {
params,
runtimeNodes,
@@ -88,6 +91,7 @@ export const dispatchIfElse = async (props: Props): Promise<DispatchNodeResultTy
});
return {
[NodeOutputKeyEnum.ifElseResult]: res,
[DispatchNodeResponseKeyEnum.nodeResponse]: {
totalPoints: 0,
ifElseResult: res