Skip to content
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

Perf ui detail #2775

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/global/core/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export const appWorkflow2Form = ({
node.inputs,
NodeInputKeyEnum.datasetSearchExtensionBg
);
} else if (node.flowNodeType === FlowNodeTypeEnum.pluginModule) {
} else if (
node.flowNodeType === FlowNodeTypeEnum.pluginModule ||
node.flowNodeType === FlowNodeTypeEnum.appModule
) {
if (!node.pluginId) return;

defaultAppForm.selectedTools.push({
Expand All @@ -108,7 +111,7 @@ export const appWorkflow2Form = ({
intro: node.intro || '',
flowNodeType: node.flowNodeType,
showStatus: node.showStatus,
version: '481',
version: node.version,
inputs: node.inputs,
outputs: node.outputs,
templateType: FlowNodeTemplateTypeEnum.other
Expand Down
4 changes: 2 additions & 2 deletions packages/global/core/workflow/template/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { VariableUpdateNode } from './system/variableUpdate';
import { CodeNode } from './system/sandbox';
import { TextEditorNode } from './system/textEditor';
import { CustomFeedbackNode } from './system/customFeedback';
import { ReadFilesNodes } from './system/readFiles';
import { ReadFilesNode } from './system/readFiles';
import { UserSelectNode } from './system/userSelect/index';
import { LoopNode } from './system/loop/loop';
import { LoopStartNode } from './system/loop/loopStart';
Expand All @@ -43,7 +43,7 @@ const systemNodes: FlowNodeTemplateType[] = [
StopToolNode,
ClassifyQuestionModule,
ContextExtractModule,
ReadFilesNodes,
ReadFilesNode,
HttpNode468,
AiQueryExtension,
LafModule,
Expand Down
2 changes: 1 addition & 1 deletion packages/global/core/workflow/template/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Input_Template_UserChatInput: FlowNodeInputItemType = {
renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea],
valueType: WorkflowIOValueTypeEnum.string,
label: i18nT('workflow:user_question'),
toolDescription: i18nT('workflow:user_question'),
toolDescription: i18nT('workflow:user_question_tool_desc'),
required: true
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { FlowNodeTemplateType } from '../../../type/node';
import { getHandleConfig } from '../../utils';

export const ReadFilesNodes: FlowNodeTemplateType = {
export const ReadFilesNode: FlowNodeTemplateType = {
id: FlowNodeTypeEnum.readFiles,
templateType: FlowNodeTemplateTypeEnum.tools,
flowNodeType: FlowNodeTypeEnum.readFiles,
Expand Down
5 changes: 5 additions & 0 deletions packages/service/core/chat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ export const loadRequestMessages = async ({
});
});

// Too many images or too long text, return text
if (httpsImages.length > 4 || input.length > 1000) {
return [{ type: 'text', text: input || '' }];
}

// 添加原始input作为文本
result.push({ type: 'text', text: input });
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,6 @@ export const runToolWithFunctionCall = async (
];
// console.log(tokens, 'tool');

// Run tool status
if (node.showStatus) {
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
}

// tool assistant
const toolAssistants = toolsRunResponse
.map((item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,6 @@ export const runToolWithPromptCall = async (
};
})();

// Run tool status
if (node.showStatus) {
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
}

// 合并工具调用的结果,使用 functionCall 格式存储。
const assistantToolMsgParams: ChatCompletionAssistantMessageParam = {
role: ChatCompletionRequestMessageRoleEnum.Assistant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,6 @@ export const runToolWithToolChoice = async (

// console.log(tokens, 'tool');

// Run tool status
if (node.showStatus) {
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
}

// tool assistant
const toolAssistants = toolsRunResponse
.map((item) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/service/core/workflow/dispatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
result: Record<string, any>;
}> {
// push run status messages
if (node.showStatus) {
if (node.showStatus && !props.isToolCall) {
props.workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/en/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
"update_specified_node_output_or_global_variable": "Can update the output value of a specified node or update global variables",
"use_user_id": "User ID",
"user_question": "User Question",
"user_question_tool_desc": "User input questions (questions need to be improved)",
"value_type": "Value type",
"variable_picker_tips": "Type node name or variable name to search",
"variable_update": "Variable Update",
Expand Down
1 change: 1 addition & 0 deletions packages/web/i18n/zh/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"update_specified_node_output_or_global_variable": "可以更新指定节点的输出值或更新全局变量",
"use_user_id": "使用者 ID",
"user_question": "用户问题",
"user_question_tool_desc": "用户输入的问题(问题需要完善)",
"value_type": "数据类型",
"variable_picker_tips": "可输入节点名或变量名搜索",
"variable_update": "变量更新",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useSystem } from '@fastgpt/web/hooks/useSystem';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { formatTime2YMDHMS } from '@fastgpt/global/common/string/time';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { useDatasetStore } from '@/web/core/dataset/store/dataset';

const Header = ({
appForm,
Expand All @@ -38,6 +39,7 @@ const Header = ({
const { toast } = useToast();
const { appId, appDetail, onSaveApp, currentTab } = useContextSelector(AppContext, (v) => v);
const { lastAppListRouteType } = useSystemStore();
const { allDatasets } = useDatasetStore();

const { data: paths = [] } = useRequest2(() => getAppFolderPath(appId), {
manual: false,
Expand Down Expand Up @@ -70,7 +72,7 @@ const Header = ({
chatConfig: data.chatConfig
}
);
}, [appDetail.chatConfig, appDetail.modules, appForm, t]);
}, [appDetail.chatConfig, appDetail.modules, appForm, allDatasets, t]);

const onSubmitPublish = useCallback(
async (data: AppSimpleEditFormType) => {
Expand Down
24 changes: 14 additions & 10 deletions projects/app/src/pages/chat/share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ type Props = {
};

const OutLink = ({
outLinkUid,
appName,
appIntro,
appAvatar
outLinkUid
}: Props & {
outLinkUid: string;
}) => {
Expand Down Expand Up @@ -232,8 +229,6 @@ const OutLink = ({

return (
<>
<NextHead title={appName} desc={appIntro} icon={appAvatar} />

<PageContainer
isLoading={loading}
{...(isEmbed
Expand Down Expand Up @@ -357,17 +352,26 @@ const OutLink = ({
const Render = (props: Props) => {
const { shareId, authToken } = props;
const { localUId, loaded } = useShareChatStore();
const [isLoaded, setIsLoaded] = useState(false);

const contextParams = useMemo(() => {
return { shareId, outLinkUid: authToken || localUId };
}, [authToken, localUId, shareId]);

if (!loaded || !contextParams.outLinkUid) return <></>;
useMount(() => {
setIsLoaded(true);
});
const systemLoaded = isLoaded && loaded && contextParams.outLinkUid;

return (
<ChatContextProvider params={contextParams}>
<OutLink {...props} outLinkUid={contextParams.outLinkUid} />;
</ChatContextProvider>
<>
<NextHead title={props.appName} desc={props.appIntro} icon={props.appAvatar} />
{systemLoaded && (
<ChatContextProvider params={contextParams}>
<OutLink {...props} outLinkUid={contextParams.outLinkUid} />;
</ChatContextProvider>
)}
</>
);
};

Expand Down
18 changes: 9 additions & 9 deletions projects/app/src/web/core/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
AiChatQuoteTemplate
} from '@fastgpt/global/core/workflow/template/system/aiChat/index';
import { DatasetSearchModule } from '@fastgpt/global/core/workflow/template/system/datasetSearch';
import { ReadFilesNodes } from '@fastgpt/global/core/workflow/template/system/readFiles';
import { ReadFilesNode } from '@fastgpt/global/core/workflow/template/system/readFiles';
import { i18nT } from '@fastgpt/web/i18n/utils';
import { Input_Template_UserChatInput } from '@fastgpt/global/core/workflow/template/input';

Expand Down Expand Up @@ -325,17 +325,17 @@ export function form2AppWorkflow(
? {
nodes: [
{
nodeId: ReadFilesNodes.id,
name: t(ReadFilesNodes.name),
intro: t(ReadFilesNodes.intro),
avatar: ReadFilesNodes.avatar,
flowNodeType: ReadFilesNodes.flowNodeType,
nodeId: ReadFilesNode.id,
name: t(ReadFilesNode.name),
intro: t(ReadFilesNode.intro),
avatar: ReadFilesNode.avatar,
flowNodeType: ReadFilesNode.flowNodeType,
showStatus: true,
position: {
x: 974.6209854328943,
y: 587.6378828744465
},
version: '489',
version: ReadFilesNode.version,
inputs: [
{
key: NodeInputKeyEnum.fileUrlList,
Expand All @@ -345,13 +345,13 @@ export function form2AppWorkflow(
value: [workflowStartNodeId, 'userFiles']
}
],
outputs: ReadFilesNodes.outputs
outputs: ReadFilesNode.outputs
}
],
edges: [
{
source: toolNodeId,
target: ReadFilesNodes.id,
target: ReadFilesNode.id,
sourceHandle: 'selectedTools',
targetHandle: 'selectedTools'
}
Expand Down
Loading