Feat: Supports to debug single component in Agent. #3993 (#4007)

### What problem does this PR solve?

Feat: Supports to debug single component in Agent. #3993
Fix: The github button on the login page is displayed incorrectly  #4002

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-12-13 14:43:24 +08:00
committed by GitHub
parent 0bca46ac3a
commit 1defe0b19b
23 changed files with 645 additions and 262 deletions

View File

@ -1,5 +1,6 @@
import { ResponseType } from '@/interfaces/database/base';
import { DSL, IFlow, IFlowTemplate } from '@/interfaces/database/flow';
import { IDebugSingleRequestBody } from '@/interfaces/request/flow';
import i18n from '@/locales/config';
import flowService from '@/services/flow-service';
import { buildMessageListWithUuid } from '@/utils/chat';
@ -220,3 +221,50 @@ export const useTestDbConnect = () => {
return { data, loading, testDbConnect: mutateAsync };
};
export const useFetchInputElements = (componentId?: string) => {
const { id } = useParams();
const { data, isPending: loading } = useQuery({
queryKey: ['fetchInputElements', id, componentId],
initialData: [],
enabled: !!id && !!componentId,
retryOnMount: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
gcTime: 0,
queryFn: async () => {
try {
const { data } = await flowService.getInputElements({
id,
component_id: componentId,
});
return data?.data ?? [];
} catch (error) {
console.log('🚀 ~ queryFn: ~ error:', error);
}
},
});
return { data, loading };
};
export const useDebugSingle = () => {
const { id } = useParams();
const {
data,
isPending: loading,
mutateAsync,
} = useMutation({
mutationKey: ['debugSingle'],
mutationFn: async (params: IDebugSingleRequestBody) => {
const ret = await flowService.debugSingle({ id, ...params });
if (ret?.data?.code !== 0) {
message.error(ret?.data?.message);
}
return ret?.data?.data;
},
});
return { data, loading, debugSingle: mutateAsync };
};