Context extract support value type (#1620)

* perf: chat box components

* perf: chatbox context

* feat: extract support value type

* workflow performance

* update doc

* feat: error response

* feat: error response

* oauth sort

* perf: logo

* fix: update laf account

* perf: team permission api

* update type
This commit is contained in:
Archer
2024-05-28 23:33:05 +08:00
committed by GitHub
parent 8ba8488086
commit 1e48922bc9
48 changed files with 232 additions and 178 deletions

View File

@@ -183,7 +183,7 @@ ${description ? `- ${description}` : ''}
> = {};
extractKeys.forEach((item) => {
properties[item.key] = {
type: 'string',
type: item.valueType || 'string',
description: item.desc,
...(item.enum ? { enum: item.enum.split('\n') } : {})
};
@@ -198,7 +198,7 @@ ${description ? `- ${description}` : ''}
required: []
}
};
console.log(properties);
return {
filterMessages,
agentFunction
@@ -319,12 +319,16 @@ const completions = async ({
content: replaceVariable(extractModel.customExtractPrompt || Prompt_ExtractJson, {
description,
json: extractKeys
.map(
(item) =>
`{"key":"${item.key}", "description":"${item.desc}"${
item.enum ? `, "enum":"[${item.enum.split('\n')}]"` : ''
}}`
)
.map((item) => {
const valueType = item.valueType || 'string';
if (valueType !== 'string' && valueType !== 'number') {
item.enum = undefined;
}
return `{"type":${item.valueType || 'string'}, "key":"${item.key}", "description":"${item.desc}" ${
item.enum ? `, "enum":"[${item.enum.split('\n')}]"` : ''
}}`;
})
.join('\n'),
text: `${histories.map((item) => `${item.obj}:${chatValue2RuntimePrompt(item.value).text}`).join('\n')}
Human: ${content}`
@@ -365,6 +369,7 @@ Human: ${content}`
arg: json5.parse(jsonStr) as Record<string, any>
};
} catch (error) {
console.log('Extract error, ai answer:', answer);
console.log(error);
return {
rawResponse: answer,

View File

@@ -45,7 +45,11 @@ export const dispatchRunCode = async (props: RunCodeType): Promise<RunCodeRespon
}
} catch (error) {
return {
[NodeOutputKeyEnum.error]: formatHttpError(error)
[NodeOutputKeyEnum.error]: formatHttpError(error),
[DispatchNodeResponseKeyEnum.nodeResponse]: {
customInputs: customVariables,
error: formatHttpError(error)
}
};
}
};