From a953217d37ab314265caa5c81acc488ec0540c2e Mon Sep 17 00:00:00 2001 From: Aarushi Date: Fri, 5 Jul 2024 15:47:58 +0100 Subject: [PATCH] setting up project structure --- .../src/{lib => api}/autogpt_server_api.ts | 66 +--------------- rnd/autogpt_builder/src/components/Flow.tsx | 2 +- .../src/constants/constants.ts | 5 ++ rnd/autogpt_builder/src/lib/types.ts | 6 -- rnd/autogpt_builder/src/types/api.ts | 75 +++++++++++++++++++ 5 files changed, 82 insertions(+), 72 deletions(-) rename rnd/autogpt_builder/src/{lib => api}/autogpt_server_api.ts (70%) create mode 100644 rnd/autogpt_builder/src/constants/constants.ts delete mode 100644 rnd/autogpt_builder/src/lib/types.ts create mode 100644 rnd/autogpt_builder/src/types/api.ts diff --git a/rnd/autogpt_builder/src/lib/autogpt_server_api.ts b/rnd/autogpt_builder/src/api/autogpt_server_api.ts similarity index 70% rename from rnd/autogpt_builder/src/lib/autogpt_server_api.ts rename to rnd/autogpt_builder/src/api/autogpt_server_api.ts index 97b34f5d3e..b052b47d45 100644 --- a/rnd/autogpt_builder/src/lib/autogpt_server_api.ts +++ b/rnd/autogpt_builder/src/api/autogpt_server_api.ts @@ -1,5 +1,4 @@ -import { XYPosition } from "reactflow"; -import { ObjectSchema } from "./types"; +import {Block, NodeExecutionResult} from "@/types/api"; export default class AutoGPTServerAPI { private baseUrl: string; @@ -127,67 +126,4 @@ export default class AutoGPTServerAPI { } } -/* Mirror of autogpt_server/data/block.py:Block */ -export type Block = { - id: string; - name: string; - description: string; - inputSchema: ObjectSchema; - outputSchema: ObjectSchema; -}; -/* Mirror of autogpt_server/data/graph.py:Node */ -export type Node = { - id: string; - block_id: string; - input_default: Map; - input_nodes: Array<{ name: string, node_id: string }>; - output_nodes: Array<{ name: string, node_id: string }>; - metadata: { - position: XYPosition; - [key: string]: any; - }; -}; - -/* Mirror of autogpt_server/data/graph.py:Link */ -export type Link = { - source_id: string; - sink_id: string; - source_name: string; - sink_name: string; -} - -/* Mirror of autogpt_server/data/graph.py:Graph */ -export type Flow = { - id: string; - name: string; - description: string; - nodes: Array; - links: Array; -}; - -export type FlowCreateBody = Flow | { - id?: string; -} - -/* Derived from autogpt_server/executor/manager.py:ExecutionManager.add_execution */ -export type FlowExecuteResponse = { - /* ID of the initiated run */ - id: string; - /* List of node executions */ - executions: Array<{ id: string, node_id: string }>; -}; - -/* Mirror of autogpt_server/data/execution.py:ExecutionResult */ -export type NodeExecutionResult = { - graph_exec_id: string; - node_exec_id: string; - node_id: string; - status: 'INCOMPLETE' | 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED'; - input_data: Map; - output_data: Map; - add_time: Date; - queue_time?: Date; - start_time?: Date; - end_time?: Date; -}; diff --git a/rnd/autogpt_builder/src/components/Flow.tsx b/rnd/autogpt_builder/src/components/Flow.tsx index fc4deadf8f..083d248d08 100644 --- a/rnd/autogpt_builder/src/components/Flow.tsx +++ b/rnd/autogpt_builder/src/components/Flow.tsx @@ -15,7 +15,7 @@ import ReactFlow, { import 'reactflow/dist/style.css'; import CustomNode from './CustomNode'; import './flow.css'; -import AutoGPTServerAPI, { Block } from '@/lib/autogpt_server_api'; +import AutoGPTServerAPI, { Block } from '@/api/autogpt_server_api'; import { ObjectSchema } from '@/lib/types'; type CustomNodeData = { diff --git a/rnd/autogpt_builder/src/constants/constants.ts b/rnd/autogpt_builder/src/constants/constants.ts new file mode 100644 index 0000000000..aaaa324063 --- /dev/null +++ b/rnd/autogpt_builder/src/constants/constants.ts @@ -0,0 +1,5 @@ +export const STATUS_INCOMPLETE = 'INCOMPLETE'; +export const STATUS_QUEUED = 'QUEUED'; +export const STATUS_RUNNING = 'RUNNING'; +export const STATUS_COMPLETED = 'COMPLETED'; +export const STATUS_FAILED = 'FAILED'; \ No newline at end of file diff --git a/rnd/autogpt_builder/src/lib/types.ts b/rnd/autogpt_builder/src/lib/types.ts deleted file mode 100644 index fae8238190..0000000000 --- a/rnd/autogpt_builder/src/lib/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type ObjectSchema = { - type: string; - properties: { [key: string]: any }; - additionalProperties?: { type: string }; - required?: string[]; - }; diff --git a/rnd/autogpt_builder/src/types/api.ts b/rnd/autogpt_builder/src/types/api.ts new file mode 100644 index 0000000000..021998c86c --- /dev/null +++ b/rnd/autogpt_builder/src/types/api.ts @@ -0,0 +1,75 @@ +import {XYPosition} from "reactflow"; +import {STATUS_COMPLETED, STATUS_FAILED, STATUS_INCOMPLETE, STATUS_QUEUED, STATUS_RUNNING} from "@/constants/constants"; + +export type ObjectSchema = { + type: string; + properties: { [key: string]: any }; + additionalProperties?: { type: string }; + required?: string[]; + }; + + +/* Mirror of autogpt_server/data/block.py:Block */ +export type Block = { + id: string; + name: string; + description: string; + inputSchema: ObjectSchema; + outputSchema: ObjectSchema; +}; + +/* Mirror of autogpt_server/data/graph.py:Node */ +export type Node = { + id: string; + block_id: string; + input_default: Map; + input_nodes: Array<{ name: string, node_id: string }>; + output_nodes: Array<{ name: string, node_id: string }>; + metadata: { + position: XYPosition; + [key: string]: any; + }; +}; + +/* Mirror of autogpt_server/data/graph.py:Link */ +export type Link = { + source_id: string; + sink_id: string; + source_name: string; + sink_name: string; +} + +/* Mirror of autogpt_server/data/graph.py:Graph */ +export type Flow = { + id: string; + name: string; + description: string; + nodes: Array; + links: Array; +}; + +export type FlowCreateBody = Flow | { + id?: string; +} + +/* Derived from autogpt_server/executor/manager.py:ExecutionManager.add_execution */ +export type FlowExecuteResponse = { + /* ID of the initiated run */ + id: string; + /* List of node executions */ + executions: Array<{ id: string, node_id: string }>; +}; + +/* Mirror of autogpt_server/data/execution.py:ExecutionResult */ +export type NodeExecutionResult = { + graph_exec_id: string; + node_exec_id: string; + node_id: string; + status: typeof STATUS_INCOMPLETE | typeof STATUS_QUEUED | typeof STATUS_RUNNING | typeof STATUS_COMPLETED | typeof STATUS_FAILED; + input_data: Map; + output_data: Map; + add_time: Date; + queue_time?: Date; + start_time?: Date; + end_time?: Date; +}; \ No newline at end of file