Handle empty action (#447)
This commit is contained in:
@@ -37,13 +37,13 @@ export type ArtifactApiResponse = {
|
|||||||
organization_id: string;
|
organization_id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ActionResultApiResponse = {
|
||||||
|
success: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type ActionAndResultApiResponse = [
|
export type ActionAndResultApiResponse = [
|
||||||
ActionApiResponse,
|
ActionApiResponse,
|
||||||
[
|
Array<ActionResultApiResponse>,
|
||||||
{
|
|
||||||
success: boolean;
|
|
||||||
},
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export type StepApiResponse = {
|
export type StepApiResponse = {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function getActionInput(action: ActionApiResponse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useActions(taskId: string): {
|
function useActions(taskId: string): {
|
||||||
data?: Array<Action>;
|
data?: Array<Action | null>;
|
||||||
isFetching: boolean;
|
isFetching: boolean;
|
||||||
} {
|
} {
|
||||||
const credentialGetter = useCredentialGetter();
|
const credentialGetter = useCredentialGetter();
|
||||||
@@ -56,16 +56,20 @@ function useActions(taskId: string): {
|
|||||||
const actionsAndResults = step.output.actions_and_results;
|
const actionsAndResults = step.output.actions_and_results;
|
||||||
|
|
||||||
const actions = actionsAndResults.map((actionAndResult, index) => {
|
const actions = actionsAndResults.map((actionAndResult, index) => {
|
||||||
const action: Action = {
|
const action = actionAndResult[0];
|
||||||
reasoning: actionAndResult[0].reasoning,
|
const actionResult = actionAndResult[1];
|
||||||
confidence: actionAndResult[0].confidence_float,
|
if (actionResult.length === 0) {
|
||||||
input: getActionInput(actionAndResult[0]),
|
return null;
|
||||||
type: actionAndResult[0].action_type,
|
}
|
||||||
success: actionAndResult[1][0].success,
|
return {
|
||||||
|
reasoning: action.reasoning,
|
||||||
|
confidence: action.confidence_float,
|
||||||
|
input: getActionInput(action),
|
||||||
|
type: action.action_type,
|
||||||
|
success: actionResult?.[0]?.success ?? false,
|
||||||
stepId: step.step_id,
|
stepId: step.step_id,
|
||||||
index,
|
index,
|
||||||
};
|
};
|
||||||
return action;
|
|
||||||
});
|
});
|
||||||
return actions;
|
return actions;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user