From a654f454b808c0e75a4166c2007e48e919419c20 Mon Sep 17 00:00:00 2001 From: "Eng. Elias" Date: Thu, 21 Mar 2024 00:43:28 +0400 Subject: [PATCH] adding the new fields of crewAI to GraphQL schema and queries and UI forms + some UI enhancements --- src/app/agents/page.tsx | 13 +++++ src/app/api/graphql/resolvers.js | 13 +---- src/app/api/graphql/schema.ts | 10 +++- src/app/missions/page.tsx | 13 +++++ .../inputs/mission_tasks_editor.tsx | 38 ++++++++----- src/components/modals/agent_modal.tsx | 49 ++++++++++++---- src/components/modals/mission_modal.tsx | 11 ++-- src/components/modals/new_agent_modal.tsx | 57 ++++++++++--------- src/components/modals/new_mission_modal.tsx | 12 ++-- src/components/ui/tasks_accordions.tsx | 15 ++++- src/data/data.ts | 17 ++++-- src/types/agent.ts | 1 + src/types/task.ts | 1 + src/utils/graphql_queries.ts | 19 ++++++- 14 files changed, 180 insertions(+), 89 deletions(-) diff --git a/src/app/agents/page.tsx b/src/app/agents/page.tsx index 42f2625..772d4b2 100644 --- a/src/app/agents/page.tsx +++ b/src/app/agents/page.tsx @@ -65,6 +65,19 @@ const AgentsPage = () => { )} + {data?.agents.length === 0 && ( +
+ + } + className="w-fit" + > + No Agents, Try to add one. + +
+ )} {data?.agents.map((agent: Agent, i: number) => (
a.id === task.agent) ?? null; - } - tasks.push({ - ...task, - agent, - }); - } const mission = await prisma.mission.create({ data: { name, verbose: !!verbose, process: process ?? Process.SEQUENTIAL, crew: { connect: crew }, - tasks, + tasks: [], result: "", }, }); diff --git a/src/app/api/graphql/schema.ts b/src/app/api/graphql/schema.ts index d122e5f..44bcf4f 100644 --- a/src/app/api/graphql/schema.ts +++ b/src/app/api/graphql/schema.ts @@ -16,6 +16,7 @@ const typeDefs = `#graphql tools: [AgentTool!]! allowDelegation: Boolean! verbose: Boolean! + memory: Boolean image: String missions: [Mission!] } @@ -31,12 +32,14 @@ const typeDefs = `#graphql type Task { name: String! description: String! + expected_output: String! agent: Agent } input TaskInput { name: String! description: String! + expected_output: String! agent: Int } @@ -74,8 +77,9 @@ const typeDefs = `#graphql goal: String! backstory: String tools: [AgentTool!] = [] - allowDelegation: Boolean = false - verbose: Boolean = false + allowDelegation: Boolean + verbose: Boolean + memory: Boolean ): Agent! updateAgent( @@ -86,6 +90,7 @@ const typeDefs = `#graphql tools: [AgentTool!] allowDelegation: Boolean verbose: Boolean + memory: Boolean ): Agent! deleteAgent(id: Int!): DeleteOutput @@ -93,7 +98,6 @@ const typeDefs = `#graphql createMission( name: String! crew: [Int!] = [] - tasks: [TaskInput!] = [] verbose: Boolean = false process: MissionProcess = "SEQUENTIAL" ): Mission! diff --git a/src/app/missions/page.tsx b/src/app/missions/page.tsx index f72023a..0674b6e 100644 --- a/src/app/missions/page.tsx +++ b/src/app/missions/page.tsx @@ -65,6 +65,19 @@ const MissionsPage = () => { }} />
+ {data?.missions.length === 0 && ( +
+ + } + className="w-fit" + > + No missions, Try to add one. + +
+ )}
{data?.missions.map((mission: Mission, i: number) => (
diff --git a/src/components/inputs/mission_tasks_editor.tsx b/src/components/inputs/mission_tasks_editor.tsx index 428c8ee..95a2edf 100644 --- a/src/components/inputs/mission_tasks_editor.tsx +++ b/src/components/inputs/mission_tasks_editor.tsx @@ -4,7 +4,7 @@ import { selectTheme } from "@/data/consts"; import { Agent } from "@/types/agent"; import { Mission } from "@/types/mission"; import { Task } from "@/types/task"; -import { Button } from "@material-tailwind/react"; +import { Button, Input, Textarea } from "@material-tailwind/react"; import React, { useState } from "react"; import { TESelect } from "tw-elements-react"; @@ -20,13 +20,15 @@ const MissionTaskEditor: React.FC = ({ onMissionChange, }) => { const [newTaskName, setNewTaskName] = useState(""); - const [newTaskAgent, setNewTaskAgent] = useState(null); const [newTaskDescription, setNewTaskDescription] = useState(""); + const [newTaskExpectedOutput, setNewTaskExpectedOutput] = useState(""); + const [newTaskAgent, setNewTaskAgent] = useState(null); const handleAddTask = () => { const newTask: Task = { name: newTaskName, description: newTaskDescription, + expected_output: newTaskExpectedOutput, agent: newTaskAgent, }; const updatedTasks = [...(mission?.tasks ?? []), newTask]; @@ -73,23 +75,31 @@ const MissionTaskEditor: React.FC = ({
- - setNewTaskName(e.target.value)} - className="border border-gray-300 text-black rounded px-3 py-1" + // className="border border-gray-300 text-black rounded px-3 py-1" + crossOrigin={undefined} + /> +
+
+