AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(rnd) Add Postgres support (#7513)
Aarushia911f9a5eb0e
diff --git a/.github/workflows/autogpt-server-ci.yml b/.github/workflows/autogpt-server-ci.ymlindex 0cb67bf678..7d012bf26d 100644--- a/.github/workflows/autogpt-server-ci.yml+++ b/.github/workflows/autogpt-server-ci.yml@@ -34,6 +34,15 @@ jobs:runs-on: ${{ matrix.platform-os != 'macos-arm64' && format('{0}-latest', matrix.platform-os) || 'macos-14' }}steps:+ - name: Setup PostgreSQL+ uses: ikalnytskyi/action-setup-postgres@v6+ with:+ username: ${{ secrets.DB_USER }}+ password: ${{ secrets.DB_PASS }}+ database: postgres+ port: 5432+ id: postgres+# Quite slow on macOS (2~4 minutes to set up Docker)# - name: Set up Docker (macOS)# if: runner.os == 'macOS'@@ -110,6 +119,8 @@ jobs:- name: Run Database Migrationsrun: poetry run prisma migrate dev --name updates+ env:+ CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}- name: Run Linterrun: poetry run lint@@ -118,159 +129,20 @@ jobs:run: |poetry run pytest -vv \test- env:- CI: true- PLAIN_OUTPUT: True- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}+ env:+ CI: true+ PLAIN_OUTPUT: True+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}+ DB_USER: ${{ secrets.DB_USER }}+ DB_PASS: ${{ secrets.DB_PASS }}+ DB_NAME: postgres+ DB_PORT: 5432+ RUN_ENV: local+ PORT: 8080+ DATABASE_URL: postgresql://${{ secrets.DB_USER }}:${{ secrets.DB_PASS }}@localhost:5432/${{ secrets.DB_NAME }}# - name: Upload coverage reports to Codecov# uses: codecov/codecov-action@v4# with:# token: ${{ secrets.CODECOV_TOKEN }}# flags: autogpt-server,${{ runner.os }}-- build:- permissions:- contents: read- timeout-minutes: 30- strategy:- fail-fast: false- matrix:- python-version: ["3.10"]- platform-os: [ubuntu, macos, macos-arm64, windows]- runs-on: ${{ matrix.platform-os != 'macos-arm64' && format('{0}-latest', matrix.platform-os) || 'macos-14' }}-- steps:- - name: Checkout repository- uses: actions/checkout@v4- with:- fetch-depth: 0- submodules: true-- - name: Set up Python ${{ matrix.python-version }}- uses: actions/setup-python@v5- with:- python-version: ${{ matrix.python-version }}-- - id: get_date- name: Get date- run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT-- - name: Set up Python dependency cache- # On Windows, unpacking cached dependencies takes longer than just installing them- if: runner.os != 'Windows'- uses: actions/cache@v4- with:- path: ${{ runner.os == 'macOS' && '~/Library/Caches/pypoetry' || '~/.cache/pypoetry' }}- key: poetry-${{ runner.os }}-${{ hashFiles('rnd/autogpt_server/poetry.lock') }}-- - name: Install Poetry (Unix)- if: runner.os != 'Windows'- run: |- curl -sSL https://install.python-poetry.org | python3 --- if [ "${{ runner.os }}" = "macOS" ]; then- PATH="$HOME/.local/bin:$PATH"- echo "$HOME/.local/bin" >> $GITHUB_PATH- fi-- - name: Install Poetry (Windows)- if: runner.os == 'Windows'- shell: pwsh- run: |- (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python --- $env:PATH += ";$env:APPDATA\Python\Scripts"- echo "$env:APPDATA\Python\Scripts" >> $env:GITHUB_PATH-- - name: Install Python dependencies- run: poetry install-- - name: Generate Prisma Client- run: poetry run prisma generate-- - name: Run Database Migrations- run: poetry run prisma migrate dev --name updates-- - name: install rpm- if: matrix.platform-os == 'ubuntu'- run: sudo apt-get install -y alien fakeroot rpm-- - name: Build distribution- run: |- case "${{ matrix.platform-os }}" in- "macos" | "macos-arm64")- ${MAC_COMMAND}- ;;- "windows")- ${WINDOWS_COMMAND}- ;;- *)- ${LINUX_COMMAND}- ;;- esac- env:- MAC_COMMAND: "poetry run poe dist_dmg"- WINDOWS_COMMAND: "poetry run poe dist_msi"- LINUX_COMMAND: "poetry run poe dist_appimage"-- - name: Zip the .app directory- if: runner.os == 'macOS'- working-directory: ${{ runner.temp }}- run: |- zip -r autogptserver-app-${{ matrix.platform-os }}.app.zip /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.app-- # break this into seperate steps each with their own name that matches the file- - name: Upload App artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-app-${{ matrix.platform-os }}- path: /Users/runner/work/_temp/autogptserver-app-${{ matrix.platform-os }}.app.zip-- - name: Upload dmg artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-dmg-${{ matrix.platform-os }}- path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/AutoGPTServer.dmg-- - name: Upload msi artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-msi-${{ matrix.platform-os }}- path: D:\a\AutoGPT\AutoGPT\rnd\autogpt_server\dist\*.msi-- - name: Upload deb artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-deb-${{ matrix.platform-os }}- path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.deb-- - name: Upload rpm artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-rpm-${{ matrix.platform-os }}- path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.rpm-- - name: Upload tar.gz artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-tar.gz-${{ matrix.platform-os }}- path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.tar.gz-- - name: Upload zip artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-zip-${{ matrix.platform-os }}- path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.zip-- - name: Upload pkg artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-pkg-${{ matrix.platform-os }}- path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/build/*.pkg-- - name: Upload AppImage artifact- uses: actions/upload-artifact@v4- with:- name: autogptserver-AppImage-${{ matrix.platform-os }}- path: /Users/runner/work/AutoGPT/AutoGPT/rnd/autogpt_server/dist/*.AppImagediff --git a/rnd/autogpt_server/.env.example b/rnd/autogpt_server/.env.examplenew file mode 100644index 0000000000..638f8bfbca--- /dev/null+++ b/rnd/autogpt_server/.env.example@@ -0,0 +1,6 @@+DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}"+DB_USER=agpt_user+DB_PASS=pass123+DB_NAME=agpt_local+DB_PORT=5432+PRISMA_SCHEMA="schema_postgres.prisma"\ No newline at end of filediff --git a/rnd/autogpt_server/README.advanced.md b/rnd/autogpt_server/README.advanced.mdnew file mode 100644index 0000000000..6f6efaeba3--- /dev/null+++ b/rnd/autogpt_server/README.advanced.md@@ -0,0 +1,67 @@+# AutoGPT Agent Server Advanced set up++This guide walks you through a dockerized set up, with an external DB (postgres)++## Setup++We use the Poetry to manage the dependencies. To set up the project, follow these steps inside this directory:++0. Install Poetry+ ```sh+ pip install poetry+ ```++1. Configure Poetry to use .venv in your project directory+ ```sh+ poetry config virtualenvs.in-project true+ ```++2. Enter the poetry shell++ ```sh+ poetry shell+ ```++3. Install dependencies++ ```sh+ poetry install+ ```++4. Generate the Prisma client++ ```sh+ poetry run prisma generate --schema postgres/schema.prisma+ ```+++ > In case Prisma generates the client for the global Python installation instead of the virtual environment, the current mitigation is to just uninstall the global Prisma package:+ >+ > ```sh+ > pip uninstall prisma+ > ```+ >+ > Then run the generation again. The path *should* look something like this:+ > `<some path>/pypoetry/virtualenvs/autogpt-server-TQIRSwR6-py3.12/bin/prisma`++5. Run the postgres database from the /rnd folder++ ```sh+ docker compose up -d+ ```++6. Run the migrations++ ```sh+ prisma migrate dev --schema postgres/schema.prisma+ ```++## Running The Server++### Starting the server directly++Run the following command:++```sh+poetry run app+```\ No newline at end of filediff --git a/rnd/autogpt_server/README.md b/rnd/autogpt_server/README.mdindex e6eae673f1..02c3be418b 100644--- a/rnd/autogpt_server/README.md+++ b/rnd/autogpt_server/README.md@@ -49,8 +49,8 @@ We use the Poetry to manage the dependencies. To set up the project, follow thes```shpoetry run prisma migrate dev- ```-+ ```+## Running The Server### Starting the server directlydiff --git a/rnd/autogpt_server/autogpt_server/data/db.py b/rnd/autogpt_server/autogpt_server/data/db.pyindex 0a92faa35d..280edbe750 100644--- a/rnd/autogpt_server/autogpt_server/data/db.py+++ b/rnd/autogpt_server/autogpt_server/data/db.py@@ -1,8 +1,15 @@+import osfrom uuid import uuid4+from dotenv import load_dotenvfrom prisma import Prismafrom pydantic import BaseModel, Field, field_validator+load_dotenv()++PRISMA_SCHEMA = os.getenv("PRISMA_SCHEMA", "schema.prisma")+os.environ["PRISMA_SCHEMA_PATH"] = PRISMA_SCHEMA+prisma = Prisma(auto_register=True)diff --git a/rnd/autogpt_server/migrations/20240722143555_migrations/migration.sql b/rnd/autogpt_server/migrations/20240722143555_migrations/migration.sqlnew file mode 100644index 0000000000..051d0a4472--- /dev/null+++ b/rnd/autogpt_server/migrations/20240722143555_migrations/migration.sql@@ -0,0 +1,94 @@+-- CreateTable+CREATE TABLE "AgentGraph" (+ "id" TEXT NOT NULL,+ "version" INTEGER NOT NULL DEFAULT 1,+ "name" TEXT,+ "description" TEXT,+ "isActive" BOOLEAN NOT NULL DEFAULT true,+ "isTemplate" BOOLEAN NOT NULL DEFAULT false,++ PRIMARY KEY ("id", "version")+);++-- CreateTable+CREATE TABLE "AgentNode" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "agentBlockId" TEXT NOT NULL,+ "agentGraphId" TEXT NOT NULL,+ "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,+ "constantInput" TEXT NOT NULL DEFAULT '{}',+ "metadata" TEXT NOT NULL DEFAULT '{}',+ CONSTRAINT "AgentNode_agentBlockId_fkey" FOREIGN KEY ("agentBlockId") REFERENCES "AgentBlock" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "AgentNode_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE+);++-- CreateTable+CREATE TABLE "AgentNodeLink" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "agentNodeSourceId" TEXT NOT NULL,+ "sourceName" TEXT NOT NULL,+ "agentNodeSinkId" TEXT NOT NULL,+ "sinkName" TEXT NOT NULL,+ CONSTRAINT "AgentNodeLink_agentNodeSourceId_fkey" FOREIGN KEY ("agentNodeSourceId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "AgentNodeLink_agentNodeSinkId_fkey" FOREIGN KEY ("agentNodeSinkId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE+);++-- CreateTable+CREATE TABLE "AgentBlock" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "name" TEXT NOT NULL,+ "inputSchema" TEXT NOT NULL,+ "outputSchema" TEXT NOT NULL+);++-- CreateTable+CREATE TABLE "AgentGraphExecution" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "agentGraphId" TEXT NOT NULL,+ "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,+ CONSTRAINT "AgentGraphExecution_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE+);++-- CreateTable+CREATE TABLE "AgentNodeExecution" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "agentGraphExecutionId" TEXT NOT NULL,+ "agentNodeId" TEXT NOT NULL,+ "executionStatus" TEXT NOT NULL,+ "addedTime" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "queuedTime" DATETIME,+ "startedTime" DATETIME,+ "endedTime" DATETIME,+ CONSTRAINT "AgentNodeExecution_agentGraphExecutionId_fkey" FOREIGN KEY ("agentGraphExecutionId") REFERENCES "AgentGraphExecution" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "AgentNodeExecution_agentNodeId_fkey" FOREIGN KEY ("agentNodeId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE+);++-- CreateTable+CREATE TABLE "AgentNodeExecutionInputOutput" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "name" TEXT NOT NULL,+ "data" TEXT NOT NULL,+ "time" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "referencedByInputExecId" TEXT,+ "referencedByOutputExecId" TEXT,+ CONSTRAINT "AgentNodeExecutionInputOutput_referencedByInputExecId_fkey" FOREIGN KEY ("referencedByInputExecId") REFERENCES "AgentNodeExecution" ("id") ON DELETE SET NULL ON UPDATE CASCADE,+ CONSTRAINT "AgentNodeExecutionInputOutput_referencedByOutputExecId_fkey" FOREIGN KEY ("referencedByOutputExecId") REFERENCES "AgentNodeExecution" ("id") ON DELETE SET NULL ON UPDATE CASCADE+);++-- CreateTable+CREATE TABLE "AgentGraphExecutionSchedule" (+ "id" TEXT NOT NULL PRIMARY KEY,+ "agentGraphId" TEXT NOT NULL,+ "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,+ "schedule" TEXT NOT NULL,+ "isEnabled" BOOLEAN NOT NULL DEFAULT true,+ "inputData" TEXT NOT NULL,+ "lastUpdated" DATETIME NOT NULL,+ CONSTRAINT "AgentGraphExecutionSchedule_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE+);++-- CreateIndex+CREATE UNIQUE INDEX "AgentBlock_name_key" ON "AgentBlock"("name");++-- CreateIndex+CREATE INDEX "AgentGraphExecutionSchedule_isEnabled_idx" ON "AgentGraphExecutionSchedule"("isEnabled");diff --git a/rnd/autogpt_server/migrations/migration_lock.toml b/rnd/autogpt_server/migrations/migration_lock.tomlnew file mode 100644index 0000000000..e5e5c4705a--- /dev/null+++ b/rnd/autogpt_server/migrations/migration_lock.toml@@ -0,0 +1,3 @@+# Please do not edit this file manually+# It should be added in your version-control system (i.e. Git)+provider = "sqlite"\ No newline at end of filediff --git a/rnd/autogpt_server/poetry.lock b/rnd/autogpt_server/poetry.lockindex 8732185aae..b21a9b9db7 100644--- a/rnd/autogpt_server/poetry.lock+++ b/rnd/autogpt_server/poetry.lock@@ -6348,4 +6348,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools",[metadata]lock-version = "2.0"python-versions = "^3.10"-content-hash = "1aadbaecdb13f497ec2d19e149160e736c464fb1863025b0b8d1674999cfd523"+content-hash = "7ff25cdc374f596ca18a2d844bb4354ac65ac5dc130e48d2172e52fec8fad299"diff --git a/rnd/autogpt_server/postgres/migrations/20240722143307_migrations/migration.sql b/rnd/autogpt_server/postgres/migrations/20240722143307_migrations/migration.sqlnew file mode 100644index 0000000000..c23105bc0a--- /dev/null+++ b/rnd/autogpt_server/postgres/migrations/20240722143307_migrations/migration.sql@@ -0,0 +1,128 @@+-- CreateTable+CREATE TABLE "AgentGraph" (+ "id" TEXT NOT NULL,+ "version" INTEGER NOT NULL DEFAULT 1,+ "name" TEXT,+ "description" TEXT,+ "isActive" BOOLEAN NOT NULL DEFAULT true,+ "isTemplate" BOOLEAN NOT NULL DEFAULT false,++ CONSTRAINT "AgentGraph_pkey" PRIMARY KEY ("id","version")+);++-- CreateTable+CREATE TABLE "AgentNode" (+ "id" TEXT NOT NULL,+ "agentBlockId" TEXT NOT NULL,+ "agentGraphId" TEXT NOT NULL,+ "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,+ "constantInput" TEXT NOT NULL DEFAULT '{}',+ "metadata" TEXT NOT NULL DEFAULT '{}',++ CONSTRAINT "AgentNode_pkey" PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "AgentNodeLink" (+ "id" TEXT NOT NULL,+ "agentNodeSourceId" TEXT NOT NULL,+ "sourceName" TEXT NOT NULL,+ "agentNodeSinkId" TEXT NOT NULL,+ "sinkName" TEXT NOT NULL,++ CONSTRAINT "AgentNodeLink_pkey" PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "AgentBlock" (+ "id" TEXT NOT NULL,+ "name" TEXT NOT NULL,+ "inputSchema" TEXT NOT NULL,+ "outputSchema" TEXT NOT NULL,++ CONSTRAINT "AgentBlock_pkey" PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "AgentGraphExecution" (+ "id" TEXT NOT NULL,+ "agentGraphId" TEXT NOT NULL,+ "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,++ CONSTRAINT "AgentGraphExecution_pkey" PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "AgentNodeExecution" (+ "id" TEXT NOT NULL,+ "agentGraphExecutionId" TEXT NOT NULL,+ "agentNodeId" TEXT NOT NULL,+ "executionStatus" TEXT NOT NULL,+ "addedTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "queuedTime" TIMESTAMP(3),+ "startedTime" TIMESTAMP(3),+ "endedTime" TIMESTAMP(3),++ CONSTRAINT "AgentNodeExecution_pkey" PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "AgentNodeExecutionInputOutput" (+ "id" TEXT NOT NULL,+ "name" TEXT NOT NULL,+ "data" TEXT NOT NULL,+ "time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "referencedByInputExecId" TEXT,+ "referencedByOutputExecId" TEXT,++ CONSTRAINT "AgentNodeExecutionInputOutput_pkey" PRIMARY KEY ("id")+);++-- CreateTable+CREATE TABLE "AgentGraphExecutionSchedule" (+ "id" TEXT NOT NULL,+ "agentGraphId" TEXT NOT NULL,+ "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,+ "schedule" TEXT NOT NULL,+ "isEnabled" BOOLEAN NOT NULL DEFAULT true,+ "inputData" TEXT NOT NULL,+ "lastUpdated" TIMESTAMP(3) NOT NULL,++ CONSTRAINT "AgentGraphExecutionSchedule_pkey" PRIMARY KEY ("id")+);++-- CreateIndex+CREATE UNIQUE INDEX "AgentBlock_name_key" ON "AgentBlock"("name");++-- CreateIndex+CREATE INDEX "AgentGraphExecutionSchedule_isEnabled_idx" ON "AgentGraphExecutionSchedule"("isEnabled");++-- AddForeignKey+ALTER TABLE "AgentNode" ADD CONSTRAINT "AgentNode_agentBlockId_fkey" FOREIGN KEY ("agentBlockId") REFERENCES "AgentBlock"("id") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentNode" ADD CONSTRAINT "AgentNode_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph"("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentNodeLink" ADD CONSTRAINT "AgentNodeLink_agentNodeSourceId_fkey" FOREIGN KEY ("agentNodeSourceId") REFERENCES "AgentNode"("id") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentNodeLink" ADD CONSTRAINT "AgentNodeLink_agentNodeSinkId_fkey" FOREIGN KEY ("agentNodeSinkId") REFERENCES "AgentNode"("id") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentGraphExecution" ADD CONSTRAINT "AgentGraphExecution_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph"("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentNodeExecution" ADD CONSTRAINT "AgentNodeExecution_agentGraphExecutionId_fkey" FOREIGN KEY ("agentGraphExecutionId") REFERENCES "AgentGraphExecution"("id") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentNodeExecution" ADD CONSTRAINT "AgentNodeExecution_agentNodeId_fkey" FOREIGN KEY ("agentNodeId") REFERENCES "AgentNode"("id") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentNodeExecutionInputOutput" ADD CONSTRAINT "AgentNodeExecutionInputOutput_referencedByInputExecId_fkey" FOREIGN KEY ("referencedByInputExecId") REFERENCES "AgentNodeExecution"("id") ON DELETE SET NULL ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentNodeExecutionInputOutput" ADD CONSTRAINT "AgentNodeExecutionInputOutput_referencedByOutputExecId_fkey" FOREIGN KEY ("referencedByOutputExecId") REFERENCES "AgentNodeExecution"("id") ON DELETE SET NULL ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "AgentGraphExecutionSchedule" ADD CONSTRAINT "AgentGraphExecutionSchedule_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph"("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE;diff --git a/rnd/autogpt_server/postgres/migrations/migration_lock.toml b/rnd/autogpt_server/postgres/migrations/migration_lock.tomlnew file mode 100644index 0000000000..fbffa92c2b--- /dev/null+++ b/rnd/autogpt_server/postgres/migrations/migration_lock.toml@@ -0,0 +1,3 @@+# Please do not edit this file manually+# It should be added in your version-control system (i.e. Git)+provider = "postgresql"\ No newline at end of filediff --git a/rnd/autogpt_server/postgres/schema.prisma b/rnd/autogpt_server/postgres/schema.prismanew file mode 100644index 0000000000..1aabe7bbfb--- /dev/null+++ b/rnd/autogpt_server/postgres/schema.prisma@@ -0,0 +1,148 @@+datasource db {+ provider = "postgresql"+ url = env("DATABASE_URL")+}++generator client {+ provider = "prisma-client-py"+ recursive_type_depth = 5+ interface = "asyncio"+}++// This model describes the Agent Graph/Flow (Multi Agent System).+model AgentGraph {+ id String @default(uuid())+ version Int @default(1)++ name String?+ description String?+ isActive Boolean @default(true)+ isTemplate Boolean @default(false)++ AgentNodes AgentNode[]+ AgentGraphExecution AgentGraphExecution[]+ AgentGraphExecutionSchedule AgentGraphExecutionSchedule[]++ @@id(name: "graphVersionId", [id, version])+}++// This model describes a single node in the Agent Graph/Flow (Multi Agent System).+model AgentNode {+ id String @id @default(uuid())++ agentBlockId String+ AgentBlock AgentBlock @relation(fields: [agentBlockId], references: [id])++ agentGraphId String+ agentGraphVersion Int @default(1)+ AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version])++ // List of consumed input, that the parent node should provide.+ Input AgentNodeLink[] @relation("AgentNodeSink")++ // List of produced output, that the child node should be executed.+ Output AgentNodeLink[] @relation("AgentNodeSource")++ // JSON serialized dict[str, str] containing predefined input values.+ constantInput String @default("{}")++ // JSON serialized dict[str, str] containing the node metadata.+ metadata String @default("{}")++ ExecutionHistory AgentNodeExecution[]+}++// This model describes the link between two AgentNodes.+model AgentNodeLink {+ id String @id @default(uuid())++ // Output of a node is connected to the source of the link.+ agentNodeSourceId String+ AgentNodeSource AgentNode @relation("AgentNodeSource", fields: [agentNodeSourceId], references: [id])+ sourceName String++ // Input of a node is connected to the sink of the link.+ agentNodeSinkId String+ AgentNodeSink AgentNode @relation("AgentNodeSink", fields: [agentNodeSinkId], references: [id])+ sinkName String+}++// This model describes a component that will be executed by the AgentNode.+model AgentBlock {+ id String @id @default(uuid())+ name String @unique++ // We allow a block to have multiple types of input & output.+ // Serialized object-typed `jsonschema` with top-level properties as input/output name.+ inputSchema String+ outputSchema String++ // Prisma requires explicit back-references.+ ReferencedByAgentNode AgentNode[]+}++// This model describes the execution of an AgentGraph.+model AgentGraphExecution {+ id String @id @default(uuid())++ agentGraphId String+ agentGraphVersion Int @default(1)+ AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version])++ AgentNodeExecutions AgentNodeExecution[]+}++// This model describes the execution of an AgentNode.+model AgentNodeExecution {+ id String @id @default(uuid())++ agentGraphExecutionId String+ AgentGraphExecution AgentGraphExecution @relation(fields: [agentGraphExecutionId], references: [id])++ agentNodeId String+ AgentNode AgentNode @relation(fields: [agentNodeId], references: [id])++ Input AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionInput")+ Output AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionOutput")++ // sqlite does not support enum+ // enum Status { INCOMPLETE, QUEUED, RUNNING, SUCCESS, FAILED }+ executionStatus String+ addedTime DateTime @default(now())+ queuedTime DateTime?+ startedTime DateTime?+ endedTime DateTime?+}++// This model describes the output of an AgentNodeExecution.+model AgentNodeExecutionInputOutput {+ id String @id @default(uuid())++ name String+ data String+ time DateTime @default(now())++ // Prisma requires explicit back-references.+ referencedByInputExecId String?+ ReferencedByInputExec AgentNodeExecution? @relation("AgentNodeExecutionInput", fields: [referencedByInputExecId], references: [id])+ referencedByOutputExecId String?+ ReferencedByOutputExec AgentNodeExecution? @relation("AgentNodeExecutionOutput", fields: [referencedByOutputExecId], references: [id])+}++// This model describes the recurring execution schedule of an Agent.+model AgentGraphExecutionSchedule {+ id String @id++ agentGraphId String+ agentGraphVersion Int @default(1)+ AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version])++ schedule String // cron expression+ isEnabled Boolean @default(true)+ inputData String // JSON serialized object++ // default and set the value on each update, lastUpdated field has no time zone.+ lastUpdated DateTime @updatedAt++ @@index([isEnabled])+}diff --git a/rnd/autogpt_server/pyproject.toml b/rnd/autogpt_server/pyproject.tomlindex d67e326854..407a4330ce 100644--- a/rnd/autogpt_server/pyproject.toml+++ b/rnd/autogpt_server/pyproject.toml@@ -36,6 +36,7 @@ anthropic = "^0.25.1"ollama = "^0.3.0"+python-dotenv = "^1.0.1"[tool.poetry.group.dev.dependencies]cx-freeze = { git = "https://github.com/ntindle/cx_Freeze.git", rev = "main", develop = true }poethepoet = "^0.26.1"diff --git a/rnd/docker-compose.yml b/rnd/docker-compose.ymlnew file mode 100644index 0000000000..3f69bfaa99--- /dev/null+++ b/rnd/docker-compose.yml@@ -0,0 +1,16 @@+version: "3"+services:+ postgres:+ image: ankane/pgvector:latest+ environment:+ POSTGRES_USER: agpt_user+ POSTGRES_PASSWORD: pass123+ POSTGRES_DB: agpt_local+ PGUSER: 5432+ healthcheck:+ test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB+ interval: 10s+ timeout: 5s+ retries: 5+ ports:+ - "5432:5432"