From 202483f47e4704f140279f2c8493f8d4975d77ec Mon Sep 17 00:00:00 2001 From: "Eng. Elias" Date: Thu, 21 Mar 2024 00:41:38 +0400 Subject: [PATCH 1/8] updating crewAI package and adding some new field to DB schema --- .../migration.sql | 2 + prisma/schema.prisma | 1 + requirements.txt | 108 ++++++++++++++++-- src/app/api/graphql/crew_ai.py | 3 + 4 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 prisma/migrations/20240320125232_update_crew_ai/migration.sql diff --git a/prisma/migrations/20240320125232_update_crew_ai/migration.sql b/prisma/migrations/20240320125232_update_crew_ai/migration.sql new file mode 100644 index 0000000..2415537 --- /dev/null +++ b/prisma/migrations/20240320125232_update_crew_ai/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Agent" ADD COLUMN "memory" BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8198d5f..5c7bcfb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -27,6 +27,7 @@ model Agent { tools AgentTool[] @default([]) allowDelegation Boolean @default(false) verbose Boolean @default(false) + memory Boolean @default(false) image String? createdAt DateTime @default(now()) diff --git a/requirements.txt b/requirements.txt index 8b4e65e..56caa65 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,106 +1,200 @@ aiohttp==3.9.3 aiosignal==1.3.1 +alembic==1.13.1 annotated-types==0.6.0 anyio==4.3.0 appdirs==1.4.4 +asgiref==3.7.2 attrs==23.2.0 backoff==2.2.1 +bcrypt==4.1.2 beautifulsoup4==4.12.3 +Brotli==1.1.0 +build==1.1.1 cachetools==5.3.2 certifi==2024.2.2 cffi==1.16.0 charset-normalizer==3.3.2 +chroma-hnswlib==0.7.3 +chromadb==0.4.24 click==8.1.7 colorama==0.4.6 -crewai==0.11.2 +coloredlogs==15.0.1 +contextlib2==21.6.0 +crewai==0.22.5 +crewai-tools==0.0.15 +cryptography==42.0.5 curl_cffi==0.6.0b9 dataclasses-json==0.6.4 +decorator==5.1.1 Deprecated==1.2.14 +deprecation==2.1.0 distro==1.9.0 docstring-parser==0.15 duckduckgo_search==4.4.3 +embedchain==0.1.97 +fastapi==0.110.0 +filelock==3.13.1 +flatbuffers==24.3.7 frozendict==2.4.0 frozenlist==1.4.1 +fsspec==2024.3.0 +gitdb==4.0.11 +GitPython==3.1.42 google-ai-generativelanguage==0.4.0 google-api-core==2.17.1 google-auth==2.28.0 +google-cloud-aiplatform==1.44.0 +google-cloud-bigquery==3.19.0 +google-cloud-core==2.4.1 +google-cloud-resource-manager==1.12.3 +google-cloud-storage==2.15.0 +google-crc32c==1.5.0 google-generativeai==0.3.2 +google-resumable-media==2.7.0 googleapis-common-protos==1.62.0 +gptcache==0.1.43 greenlet==3.0.3 +grpc-google-iam-v1==0.13.0 grpcio==1.60.1 grpcio-status==1.60.1 h11==0.14.0 html5lib==1.1 httpcore==1.0.3 +httptools==0.6.1 httpx==0.26.0 +huggingface-hub==0.21.4 +humanfriendly==10.0 idna==3.6 importlib-metadata==6.11.0 +importlib_resources==6.3.1 +iniconfig==2.0.0 instructor==0.5.2 jsonpatch==1.33 jsonpointer==2.4 -langchain==0.1.8 -langchain-community==0.0.21 -langchain-core==0.1.24 +kubernetes==29.0.0 +lancedb==0.5.7 +langchain==0.1.12 +langchain-community==0.0.28 +langchain-core==0.1.32 langchain-experimental==0.0.52 langchain-google-genai==0.0.9 langchain-openai==0.0.5 -langsmith==0.1.3 +langchain-text-splitters==0.0.1 +langsmith==0.1.27 lxml==5.1.0 +Mako==1.3.2 markdown-it-py==3.0.0 +MarkupSafe==2.1.5 marshmallow==3.20.2 mdurl==0.1.2 mediawikiapi==1.2 +mmh3==4.1.0 +monotonic==1.6 +mpmath==1.3.0 multidict==6.0.5 multitasking==0.0.11 +mutagen==1.47.0 mypy-extensions==1.0.0 nest-asyncio==1.6.0 +nodeenv==1.8.0 numpy==1.26.4 -openai==1.12.0 +oauthlib==3.2.2 +onnxruntime==1.17.1 +openai==1.14.1 opentelemetry-api==1.22.0 opentelemetry-exporter-otlp-proto-common==1.22.0 +opentelemetry-exporter-otlp-proto-grpc==1.22.0 opentelemetry-exporter-otlp-proto-http==1.22.0 +opentelemetry-instrumentation==0.43b0 +opentelemetry-instrumentation-asgi==0.43b0 +opentelemetry-instrumentation-fastapi==0.43b0 opentelemetry-proto==1.22.0 opentelemetry-sdk==1.22.0 opentelemetry-semantic-conventions==0.43b0 +opentelemetry-util-http==0.43b0 +orjson==3.9.15 +outcome==1.3.0.post0 +overrides==7.7.0 packaging==23.2 pandas==2.2.0 peewee==3.17.1 +pluggy==1.4.0 +posthog==3.5.0 proto-plus==1.23.0 protobuf==4.25.3 +pulsar-client==3.4.0 +py==1.11.0 +pyarrow==15.0.1 pyasn1==0.5.1 pyasn1-modules==0.3.0 pycparser==2.21 +pycryptodomex==3.20.0 pydantic==2.6.1 pydantic_core==2.16.2 +PyGithub==1.59.1 Pygments==2.17.2 +PyJWT==2.8.0 +pylance==0.9.18 +PyNaCl==1.5.0 +pypdf==3.17.4 +PyPika==0.48.9 +pyproject_hooks==1.0.0 +pyreadline3==3.4.1 +pyright==1.1.354 +pysbd==0.3.4 +PySocks==1.7.1 +pytest==8.1.1 python-dateutil==2.8.2 -python-dotenv==1.0.1 +python-dotenv==1.0.0 +pytube==15.0.0 pytz==2024.1 PyYAML==6.0.1 +ratelimiter==1.2.0.post0 regex==2023.12.25 requests==2.31.0 +requests-oauthlib==1.4.0 +retry==0.9.2 rich==13.7.0 rsa==4.9 +schema==0.7.5 +selenium==4.18.1 semanticscholar==0.7.0 +semver==3.0.2 +shapely==2.0.3 six==1.16.0 +smmap==5.0.1 sniffio==1.3.0 +sortedcontainers==2.4.0 soupsieve==2.5 SQLAlchemy==2.0.27 StackAPI==0.3.0 +starlette==0.36.3 +sympy==1.12 tenacity==8.2.3 tiktoken==0.5.2 +tokenizers==0.15.2 tqdm==4.66.2 +trio==0.24.0 +trio-websocket==0.11.1 typer==0.9.0 typing-inspect==0.9.0 typing_extensions==4.9.0 tzdata==2024.1 urllib3==2.2.1 +uvicorn==0.28.0 +watchfiles==0.21.0 webencodings==0.5.1 +websocket-client==1.7.0 +websockets==12.0 wikibase-rest-api-client==0.1.3 wikipedia==1.4.0 wrapt==1.16.0 +wsproto==1.2.0 xmltodict==0.13.0 yarl==1.9.4 yfinance==0.2.36 youtube-search==2.1.2 +youtube-transcript-api==0.6.2 +yt-dlp==2023.12.30 zipp==3.17.0 diff --git a/src/app/api/graphql/crew_ai.py b/src/app/api/graphql/crew_ai.py index 594f7ee..1249a2c 100644 --- a/src/app/api/graphql/crew_ai.py +++ b/src/app/api/graphql/crew_ai.py @@ -47,6 +47,8 @@ def run_mission(mission): verbose=agent["verbose"], tools=[tool_dict[tool] for tool in agent["tools"]], llm=llm, + max_rpm=60 / len(mission["crew"]), + memory=agent.get("memory", False), ) for agent in mission["crew"] ] @@ -61,6 +63,7 @@ def run_mission(mission): if task["agent"] else None ), + expected_output=task["expected_output"], ) for task in mission["tasks"] ] From a654f454b808c0e75a4166c2007e48e919419c20 Mon Sep 17 00:00:00 2001 From: "Eng. Elias" Date: Thu, 21 Mar 2024 00:43:28 +0400 Subject: [PATCH 2/8] 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} + /> +
+
+