mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-08 22:05:08 -05:00
Compare commits
1 Commits
fix/execut
...
lluisagust
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77dbb18f92 |
@@ -1,33 +1,21 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, {
|
import { BlocksControl } from "@/app/(platform)/build/components/legacy-builder/BlocksControl";
|
||||||
createContext,
|
|
||||||
useState,
|
|
||||||
useCallback,
|
|
||||||
useEffect,
|
|
||||||
useMemo,
|
|
||||||
useRef,
|
|
||||||
MouseEvent,
|
|
||||||
Suspense,
|
|
||||||
} from "react";
|
|
||||||
import Link from "next/link";
|
|
||||||
import {
|
import {
|
||||||
ReactFlow,
|
Control,
|
||||||
ReactFlowProvider,
|
ControlPanel,
|
||||||
Controls,
|
} from "@/app/(platform)/build/components/legacy-builder/ControlPanel";
|
||||||
Background,
|
import { GraphSearchControl } from "@/app/(platform)/build/components/legacy-builder/GraphSearchControl";
|
||||||
Node,
|
import OttoChatWidget from "@/app/(platform)/build/components/legacy-builder/OttoChatWidget";
|
||||||
OnConnect,
|
import { SaveControl } from "@/app/(platform)/build/components/legacy-builder/SaveControl";
|
||||||
Connection,
|
import NewControlPanel from "@/app/(platform)/build/components/NewControlPanel/NewControlPanel";
|
||||||
MarkerType,
|
import { IconRedo2, IconUndo2 } from "@/components/__legacy__/ui/icons";
|
||||||
NodeChange,
|
import {
|
||||||
EdgeChange,
|
Alert,
|
||||||
useReactFlow,
|
AlertDescription,
|
||||||
applyEdgeChanges,
|
AlertTitle,
|
||||||
applyNodeChanges,
|
} from "@/components/molecules/Alert/Alert";
|
||||||
} from "@xyflow/react";
|
import { useToast } from "@/components/molecules/Toast/use-toast";
|
||||||
import "@xyflow/react/dist/style.css";
|
import useAgentGraph from "@/hooks/useAgentGraph";
|
||||||
import { CustomNode } from "../CustomNode/CustomNode";
|
|
||||||
import "./flow.css";
|
|
||||||
import {
|
import {
|
||||||
BlockUIType,
|
BlockUIType,
|
||||||
formatEdgeID,
|
formatEdgeID,
|
||||||
@@ -35,35 +23,47 @@ import {
|
|||||||
GraphID,
|
GraphID,
|
||||||
LibraryAgent,
|
LibraryAgent,
|
||||||
} from "@/lib/autogpt-server-api";
|
} from "@/lib/autogpt-server-api";
|
||||||
import { Key, storage } from "@/services/storage/local-storage";
|
|
||||||
import { findNewlyAddedBlockCoordinates, getTypeColor } from "@/lib/utils";
|
import { findNewlyAddedBlockCoordinates, getTypeColor } from "@/lib/utils";
|
||||||
import { history } from "../history";
|
|
||||||
import { CustomEdge } from "../CustomEdge/CustomEdge";
|
|
||||||
import ConnectionLine from "../ConnectionLine";
|
|
||||||
import {
|
|
||||||
Control,
|
|
||||||
ControlPanel,
|
|
||||||
} from "@/app/(platform)/build/components/legacy-builder/ControlPanel";
|
|
||||||
import { SaveControl } from "@/app/(platform)/build/components/legacy-builder/SaveControl";
|
|
||||||
import { BlocksControl } from "@/app/(platform)/build/components/legacy-builder/BlocksControl";
|
|
||||||
import { GraphSearchControl } from "@/app/(platform)/build/components/legacy-builder/GraphSearchControl";
|
|
||||||
import { IconUndo2, IconRedo2 } from "@/components/__legacy__/ui/icons";
|
|
||||||
import {
|
|
||||||
Alert,
|
|
||||||
AlertDescription,
|
|
||||||
AlertTitle,
|
|
||||||
} from "@/components/molecules/Alert/Alert";
|
|
||||||
import { startTutorial } from "../tutorial";
|
|
||||||
import useAgentGraph from "@/hooks/useAgentGraph";
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
|
||||||
import { useRouter, usePathname, useSearchParams } from "next/navigation";
|
|
||||||
import RunnerUIWrapper, { RunnerUIWrapperRef } from "../RunnerUIWrapper";
|
|
||||||
import OttoChatWidget from "@/app/(platform)/build/components/legacy-builder/OttoChatWidget";
|
|
||||||
import { useToast } from "@/components/molecules/Toast/use-toast";
|
|
||||||
import { useCopyPaste } from "../useCopyPaste";
|
|
||||||
import NewControlPanel from "@/app/(platform)/build/components/NewControlPanel/NewControlPanel";
|
|
||||||
import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
|
import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
|
||||||
|
import { Key, storage } from "@/services/storage/local-storage";
|
||||||
|
import {
|
||||||
|
applyEdgeChanges,
|
||||||
|
applyNodeChanges,
|
||||||
|
Background,
|
||||||
|
Connection,
|
||||||
|
Controls,
|
||||||
|
EdgeChange,
|
||||||
|
MarkerType,
|
||||||
|
Node,
|
||||||
|
NodeChange,
|
||||||
|
OnConnect,
|
||||||
|
ReactFlow,
|
||||||
|
ReactFlowProvider,
|
||||||
|
useReactFlow,
|
||||||
|
} from "@xyflow/react";
|
||||||
|
import "@xyflow/react/dist/style.css";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||||
|
import React, {
|
||||||
|
createContext,
|
||||||
|
MouseEvent,
|
||||||
|
Suspense,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import { BuildActionBar } from "../BuildActionBar";
|
import { BuildActionBar } from "../BuildActionBar";
|
||||||
|
import ConnectionLine from "../ConnectionLine";
|
||||||
|
import { CustomEdge } from "../CustomEdge/CustomEdge";
|
||||||
|
import { CustomNode } from "../CustomNode/CustomNode";
|
||||||
|
import { history } from "../history";
|
||||||
|
import RunnerUIWrapper, { RunnerUIWrapperRef } from "../RunnerUIWrapper";
|
||||||
|
import { startTutorial } from "../tutorial";
|
||||||
|
import { useCopyPaste } from "../useCopyPaste";
|
||||||
|
import "./flow.css";
|
||||||
|
|
||||||
// This is for the history, this is the minimum distance a block must move before it is logged
|
// This is for the history, this is the minimum distance a block must move before it is logged
|
||||||
// It helps to prevent spamming the history with small movements especially when pressing on a input in a block
|
// It helps to prevent spamming the history with small movements especially when pressing on a input in a block
|
||||||
@@ -762,6 +762,10 @@ const FlowEditor: React.FC<{
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleSaveAgent = useCallback(async () => {
|
||||||
|
await saveAgent();
|
||||||
|
}, [saveAgent]);
|
||||||
|
|
||||||
const handleRunButton = useCallback(async () => {
|
const handleRunButton = useCallback(async () => {
|
||||||
if (isRunning) return;
|
if (isRunning) return;
|
||||||
if (!savedAgent) {
|
if (!savedAgent) {
|
||||||
@@ -770,8 +774,10 @@ const FlowEditor: React.FC<{
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await saveAgent();
|
const saved = await saveAgent();
|
||||||
runnerUIRef.current?.runOrOpenInput();
|
if (saved) {
|
||||||
|
runnerUIRef.current?.runOrOpenInput(saved);
|
||||||
|
}
|
||||||
}, [isRunning, savedAgent, toast, saveAgent]);
|
}, [isRunning, savedAgent, toast, saveAgent]);
|
||||||
|
|
||||||
const handleScheduleButton = useCallback(async () => {
|
const handleScheduleButton = useCallback(async () => {
|
||||||
@@ -946,7 +952,7 @@ const FlowEditor: React.FC<{
|
|||||||
<SaveControl
|
<SaveControl
|
||||||
agentMeta={savedAgent}
|
agentMeta={savedAgent}
|
||||||
canSave={!isSaving && !isRunning && !isStopping}
|
canSave={!isSaving && !isRunning && !isStopping}
|
||||||
onSave={saveAgent}
|
onSave={handleSaveAgent}
|
||||||
agentDescription={agentDescription}
|
agentDescription={agentDescription}
|
||||||
onDescriptionChange={setAgentDescription}
|
onDescriptionChange={setAgentDescription}
|
||||||
agentName={agentName}
|
agentName={agentName}
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
import React, {
|
|
||||||
useState,
|
|
||||||
forwardRef,
|
|
||||||
useImperativeHandle,
|
|
||||||
useMemo,
|
|
||||||
} from "react";
|
|
||||||
import { Node } from "@xyflow/react";
|
|
||||||
import { CustomNodeData } from "@/app/(platform)/build/components/legacy-builder/CustomNode/CustomNode";
|
import { CustomNodeData } from "@/app/(platform)/build/components/legacy-builder/CustomNode/CustomNode";
|
||||||
import {
|
import {
|
||||||
BlockUIType,
|
BlockUIType,
|
||||||
CredentialsMetaInput,
|
CredentialsMetaInput,
|
||||||
GraphMeta,
|
GraphMeta,
|
||||||
} from "@/lib/autogpt-server-api/types";
|
} from "@/lib/autogpt-server-api/types";
|
||||||
import RunnerOutputUI, { OutputNodeInfo } from "./RunnerOutputUI";
|
import { Node } from "@xyflow/react";
|
||||||
|
import { forwardRef, useImperativeHandle, useMemo, useState } from "react";
|
||||||
import { RunnerInputDialog } from "./RunnerInputUI";
|
import { RunnerInputDialog } from "./RunnerInputUI";
|
||||||
|
import RunnerOutputUI, { OutputNodeInfo } from "./RunnerOutputUI";
|
||||||
|
|
||||||
interface RunnerUIWrapperProps {
|
interface RunnerUIWrapperProps {
|
||||||
graph: GraphMeta;
|
graph: GraphMeta;
|
||||||
@@ -33,7 +28,7 @@ interface RunnerUIWrapperProps {
|
|||||||
export interface RunnerUIWrapperRef {
|
export interface RunnerUIWrapperRef {
|
||||||
openRunInputDialog: () => void;
|
openRunInputDialog: () => void;
|
||||||
openRunnerOutput: () => void;
|
openRunnerOutput: () => void;
|
||||||
runOrOpenInput: () => void;
|
runOrOpenInput: (graphOverride?: GraphMeta) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RunnerUIWrapper = forwardRef<RunnerUIWrapperRef, RunnerUIWrapperProps>(
|
const RunnerUIWrapper = forwardRef<RunnerUIWrapperRef, RunnerUIWrapperProps>(
|
||||||
@@ -43,8 +38,8 @@ const RunnerUIWrapper = forwardRef<RunnerUIWrapperRef, RunnerUIWrapperProps>(
|
|||||||
) => {
|
) => {
|
||||||
const [isRunInputDialogOpen, setIsRunInputDialogOpen] = useState(false);
|
const [isRunInputDialogOpen, setIsRunInputDialogOpen] = useState(false);
|
||||||
const [isRunnerOutputOpen, setIsRunnerOutputOpen] = useState(false);
|
const [isRunnerOutputOpen, setIsRunnerOutputOpen] = useState(false);
|
||||||
|
const [graphOverride, setGraphOverride] = useState<GraphMeta | null>(null);
|
||||||
const graphInputs = graph.input_schema.properties;
|
const graphToUse = graphOverride || graph;
|
||||||
|
|
||||||
const graphOutputs = useMemo((): OutputNodeInfo[] => {
|
const graphOutputs = useMemo((): OutputNodeInfo[] => {
|
||||||
const outputNodes = nodes.filter(
|
const outputNodes = nodes.filter(
|
||||||
@@ -71,10 +66,17 @@ const RunnerUIWrapper = forwardRef<RunnerUIWrapperRef, RunnerUIWrapperProps>(
|
|||||||
const openRunInputDialog = () => setIsRunInputDialogOpen(true);
|
const openRunInputDialog = () => setIsRunInputDialogOpen(true);
|
||||||
const openRunnerOutput = () => setIsRunnerOutputOpen(true);
|
const openRunnerOutput = () => setIsRunnerOutputOpen(true);
|
||||||
|
|
||||||
const runOrOpenInput = () => {
|
const runOrOpenInput = (graphOverrideParam?: GraphMeta) => {
|
||||||
|
if (graphOverrideParam) {
|
||||||
|
setGraphOverride(graphOverrideParam);
|
||||||
|
}
|
||||||
|
const graphToCheck = graphOverrideParam || graph;
|
||||||
|
const inputs = graphToCheck.input_schema.properties;
|
||||||
|
const credentials = graphToCheck.credentials_input_schema.properties;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Object.keys(graphInputs).length > 0 ||
|
Object.keys(inputs).length > 0 ||
|
||||||
Object.keys(graph.credentials_input_schema.properties).length > 0
|
Object.keys(credentials).length > 0
|
||||||
) {
|
) {
|
||||||
openRunInputDialog();
|
openRunInputDialog();
|
||||||
} else {
|
} else {
|
||||||
@@ -96,8 +98,11 @@ const RunnerUIWrapper = forwardRef<RunnerUIWrapperRef, RunnerUIWrapperProps>(
|
|||||||
<>
|
<>
|
||||||
<RunnerInputDialog
|
<RunnerInputDialog
|
||||||
isOpen={isRunInputDialogOpen}
|
isOpen={isRunInputDialogOpen}
|
||||||
doClose={() => setIsRunInputDialogOpen(false)}
|
doClose={() => {
|
||||||
graph={graph}
|
setIsRunInputDialogOpen(false);
|
||||||
|
setGraphOverride(null);
|
||||||
|
}}
|
||||||
|
graph={graphToUse}
|
||||||
doRun={saveAndRun}
|
doRun={saveAndRun}
|
||||||
doCreateSchedule={createRunSchedule}
|
doCreateSchedule={createRunSchedule}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { CustomEdge } from "@/app/(platform)/build/components/legacy-builder/CustomEdge/CustomEdge";
|
import { CustomEdge } from "@/app/(platform)/build/components/legacy-builder/CustomEdge/CustomEdge";
|
||||||
import { CustomNode } from "@/app/(platform)/build/components/legacy-builder/CustomNode/CustomNode";
|
import { CustomNode } from "@/app/(platform)/build/components/legacy-builder/CustomNode/CustomNode";
|
||||||
|
import { getGetV2ListLibraryAgentsQueryKey } from "@/app/api/__generated__/endpoints/library/library";
|
||||||
import { useToast } from "@/components/molecules/Toast/use-toast";
|
import { useToast } from "@/components/molecules/Toast/use-toast";
|
||||||
import {
|
import {
|
||||||
ApiError,
|
ApiError,
|
||||||
@@ -15,20 +16,19 @@ import {
|
|||||||
GraphMeta,
|
GraphMeta,
|
||||||
LibraryAgent,
|
LibraryAgent,
|
||||||
LinkCreatable,
|
LinkCreatable,
|
||||||
|
Node,
|
||||||
NodeCreatable,
|
NodeCreatable,
|
||||||
NodeExecutionResult,
|
NodeExecutionResult,
|
||||||
Node,
|
|
||||||
} from "@/lib/autogpt-server-api";
|
} from "@/lib/autogpt-server-api";
|
||||||
import { useBackendAPI } from "@/lib/autogpt-server-api/context";
|
import { useBackendAPI } from "@/lib/autogpt-server-api/context";
|
||||||
import { deepEquals, getTypeColor, pruneEmptyValues } from "@/lib/utils";
|
import { deepEquals, getTypeColor, pruneEmptyValues } from "@/lib/utils";
|
||||||
|
import { useOnboarding } from "@/providers/onboarding/onboarding-provider";
|
||||||
|
import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import { MarkerType } from "@xyflow/react";
|
import { MarkerType } from "@xyflow/react";
|
||||||
import { default as NextLink } from "next/link";
|
import { default as NextLink } from "next/link";
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
|
|
||||||
import { useOnboarding } from "@/providers/onboarding/onboarding-provider";
|
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { getGetV2ListLibraryAgentsQueryKey } from "@/app/api/__generated__/endpoints/library/library";
|
|
||||||
|
|
||||||
export default function useAgentGraph(
|
export default function useAgentGraph(
|
||||||
flowID?: GraphID,
|
flowID?: GraphID,
|
||||||
@@ -734,17 +734,18 @@ export default function useAgentGraph(
|
|||||||
resetEdgeBeads,
|
resetEdgeBeads,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const saveAgent = useCallback(async () => {
|
const saveAgent = useCallback(async (): Promise<Graph | null> => {
|
||||||
console.log("saveAgent");
|
console.log("saveAgent");
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
try {
|
try {
|
||||||
await _saveAgent();
|
const saved = await _saveAgent();
|
||||||
|
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
queryKey: getGetV2ListLibraryAgentsQueryKey(),
|
queryKey: getGetV2ListLibraryAgentsQueryKey(),
|
||||||
});
|
});
|
||||||
|
|
||||||
completeStep("BUILDER_SAVE_AGENT");
|
completeStep("BUILDER_SAVE_AGENT");
|
||||||
|
return saved;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage =
|
const errorMessage =
|
||||||
error instanceof Error ? error.message : String(error);
|
error instanceof Error ? error.message : String(error);
|
||||||
@@ -754,10 +755,11 @@ export default function useAgentGraph(
|
|||||||
title: "Error saving agent",
|
title: "Error saving agent",
|
||||||
description: errorMessage,
|
description: errorMessage,
|
||||||
});
|
});
|
||||||
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
setIsSaving(false);
|
setIsSaving(false);
|
||||||
}
|
}
|
||||||
}, [_saveAgent, toast, completeStep]);
|
}, [_saveAgent, toast, completeStep, queryClient]);
|
||||||
|
|
||||||
const saveAndRun = useCallback(
|
const saveAndRun = useCallback(
|
||||||
async (
|
async (
|
||||||
|
|||||||
Reference in New Issue
Block a user