mirror of
https://github.com/Significant-Gravitas/AutoGPT-Code-Ability.git
synced 2026-11-11 00:21:27 -10:00
337 lines
11 KiB
Plaintext
337 lines
11 KiB
Plaintext
// datasource db defines the database connection settings.
|
|
// It is configured for PostgreSQL and uses an environment variable for the connection URL.
|
|
// The 'extensions' feature enables the use of PostgreSQL-specific data types.
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
extensions = [vector]
|
|
}
|
|
|
|
// generator db configures Prisma Client settings.
|
|
// It is set up to use Prisma Client Python with asyncio interface and specific features.
|
|
generator db {
|
|
provider = "prisma-client-py"
|
|
interface = "asyncio"
|
|
recursive_type_depth = 5
|
|
previewFeatures = ["postgresqlExtensions"]
|
|
}
|
|
|
|
// ---------------------------------------------------------------------- //
|
|
// ------------------------- Common Models ------------------------------ //
|
|
// ---------------------------------------------------------------------- //
|
|
|
|
model User {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
// This should probably have a shared id with Cloud Services so that we can look up users across them
|
|
cloudServicesId String @unique
|
|
discordId String @unique
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
lastSeen DateTime?
|
|
role Role @default(USER)
|
|
deleted Boolean @default(false)
|
|
|
|
Applications Application[]
|
|
Specifications Specification[]
|
|
LLMCallAttempts LLMCallAttempt[]
|
|
Deployments Deployment[]
|
|
CompletedApp CompletedApp[]
|
|
}
|
|
|
|
enum Role {
|
|
USER
|
|
ADMIN
|
|
}
|
|
|
|
model Application {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
name String
|
|
description String?
|
|
deleted Boolean @default(false)
|
|
|
|
Specifications Specification[]
|
|
CompletedApps CompletedApp[]
|
|
Deployments Deployment[]
|
|
LLMCallAttempts LLMCallAttempt[]
|
|
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String?
|
|
}
|
|
|
|
// ------------------------- Requirements Models ------------------------------ //
|
|
// ApplicationRequirements represents the requirements for a specific application.
|
|
// ------------------------- -------------------------------------------------- //
|
|
|
|
model Specification {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
deleted Boolean @default(false)
|
|
name String
|
|
context String
|
|
|
|
ApiRouteSpecs APIRouteSpec[]
|
|
CompletedApps CompletedApp[]
|
|
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String?
|
|
Application Application? @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
applicationId String?
|
|
}
|
|
|
|
enum AccessLevel {
|
|
PUBLIC
|
|
USER
|
|
ADMIN
|
|
}
|
|
|
|
enum HTTPVerb {
|
|
GET
|
|
POST
|
|
PUT
|
|
PATCH
|
|
DELETE
|
|
OPTIONS
|
|
HEAD
|
|
CONNECT
|
|
TRACE
|
|
}
|
|
|
|
model APIRouteSpec {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
functionName String
|
|
method HTTPVerb
|
|
path String
|
|
description String
|
|
AccessLevel AccessLevel
|
|
|
|
Functions Function[]
|
|
CompiledRoutes CompiledRoute[]
|
|
|
|
Specification Specification? @relation(fields: [specificationId], references: [id], onDelete: Cascade)
|
|
specificationId String?
|
|
ResponseObject ResponseObject? @relation(fields: [responseObjectId], references: [id], onDelete: Cascade)
|
|
responseObjectId String?
|
|
RequestObject RequestObject? @relation(fields: [requestObjectId], references: [id], onDelete: Cascade)
|
|
requestObjectId String?
|
|
DatabaseSchema DatabaseSchema? @relation(fields: [databaseSchemaId], references: [id], onDelete: Cascade)
|
|
databaseSchemaId String?
|
|
}
|
|
|
|
model ResponseObject {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
name String
|
|
description String
|
|
|
|
ApiRouteSpecs APIRouteSpec[]
|
|
Params Param[]
|
|
}
|
|
|
|
model RequestObject {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
name String
|
|
description String
|
|
|
|
ApiRouteSpecs APIRouteSpec[]
|
|
Params Param[]
|
|
}
|
|
|
|
model Param {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
name String
|
|
description String
|
|
paramType String
|
|
|
|
ResponseObject ResponseObject? @relation(fields: [responseObjectId], references: [id])
|
|
responseObjectId String?
|
|
RequestObject RequestObject? @relation(fields: [requestObjectId], references: [id])
|
|
requestObjectId String?
|
|
}
|
|
|
|
// DatabaseSchema represents the schema of a database.
|
|
// It includes a description and relationships to database tables and code graphs.
|
|
model DatabaseSchema {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
name String?
|
|
createdAt DateTime @default(now())
|
|
embedding Unsupported("vector(1536)")?
|
|
description String
|
|
DatabaseTables DatabaseTable[]
|
|
Functions Function[]
|
|
ApiRouteSpecs APIRouteSpec[]
|
|
}
|
|
|
|
// DatabaseTable represents a table within a database schema.
|
|
// It includes details about the table and relationships to schemas and other tables.
|
|
model DatabaseTable {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
name String?
|
|
createdAt DateTime @default(now())
|
|
embedding Unsupported("vector(1536)")?
|
|
description String
|
|
definition String
|
|
|
|
// This seems like its gonna be a nightmare to keep track of for 1-1 1-M and M-M relationships
|
|
RelatedFromTables DatabaseTable[] @relation("TableRelations")
|
|
RelatedToTables DatabaseTable[] @relation("TableRelations")
|
|
DatabaseSchema DatabaseSchema? @relation(fields: [databaseSchemaId], references: [id])
|
|
databaseSchemaId String?
|
|
}
|
|
|
|
// ------------------------- Developer Models ---------------------------- //
|
|
// Database models for the developer
|
|
// ------------------------------------------------------------------------ //
|
|
enum FunctionState {
|
|
DEFINITION
|
|
WRITTEN
|
|
VERIFIED
|
|
}
|
|
|
|
// CodeGraph represents a graph-based representation of code or logic.
|
|
// It is associated with function definitions and can be linked to a database schema.
|
|
model Function {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
functionName String
|
|
template String // This is the template of the function along with the docstring
|
|
state FunctionState
|
|
|
|
Packages Package[]
|
|
rawCode String? // This is the unpocessed code returned form the llm
|
|
importStatements String[] // These are the import statements for the function
|
|
functionCode String? // This is the code of the function being written
|
|
|
|
ParentFunction Function? @relation("ParentFunction", fields: [parentFunctionId], references: [id], onDelete: Cascade)
|
|
parentFunctionId String?
|
|
ChildFunction Function[] @relation("ParentFunction")
|
|
|
|
ApiRouteSpec APIRouteSpec? @relation(fields: [apiRouteSpecId], references: [id], onDelete: Cascade)
|
|
apiRouteSpecId String?
|
|
DatabaseSchema DatabaseSchema? @relation(fields: [databaseSchemaId], references: [id], onDelete: Cascade)
|
|
databaseSchemaId String?
|
|
CompiledRoute CompiledRoute[]
|
|
compiledRouteId String? @unique
|
|
}
|
|
|
|
model Package {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
packageName String
|
|
version String
|
|
specifier String
|
|
Functions Function[]
|
|
CompiledRoutes CompiledRoute[]
|
|
}
|
|
|
|
// ------------------------- Delivery Models ----------------------------- //
|
|
|
|
// CompiledRoute represents a version of a route that has been processed or compiled.
|
|
// It links to its source code graph and associated functions and applications.
|
|
model CompiledRoute {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
embedding Unsupported("vector(1536)")?
|
|
description String
|
|
Packages Package[]
|
|
|
|
fileName String
|
|
mainFunctionName String
|
|
compiledCode String
|
|
|
|
CompletedApps CompletedApp[]
|
|
|
|
rootFunctionId String
|
|
RootFunction Function @relation(fields: [rootFunctionId], references: [id], onDelete: Cascade)
|
|
|
|
ApiRouteSpec APIRouteSpec? @relation(fields: [apiRouteSpecId], references: [id], onDelete: Cascade)
|
|
apiRouteSpecId String?
|
|
}
|
|
|
|
// Application represents the main software application entity.
|
|
// It includes basic metadata and has relationships with compiled routes.
|
|
model CompletedApp {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
deleted Boolean @default(false)
|
|
name String
|
|
description String
|
|
|
|
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String?
|
|
CompiledRoutes CompiledRoute[]
|
|
Deployments Deployment[]
|
|
Specification Specification? @relation(fields: [specificationId], references: [id], onDelete: Cascade)
|
|
specificationId String?
|
|
Application Application? @relation(fields: [applicationId], references: [id])
|
|
applicationId String?
|
|
}
|
|
|
|
// ---------------------------------------------------------------------- //
|
|
// ------------------------- Deployment Model --------------------------- //
|
|
// ---------------------------------------------------------------------- //
|
|
|
|
model Deployment {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
deleted Boolean @default(false)
|
|
fileName String
|
|
fileSize Int
|
|
path String?
|
|
fileBytes Bytes?
|
|
|
|
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String?
|
|
Application Application? @relation(fields: [applicationId], references: [id])
|
|
applicationId String?
|
|
CompletedApp CompletedApp? @relation(fields: [completedAppId], references: [id], onDelete: Cascade)
|
|
completedAppId String?
|
|
}
|
|
|
|
// ------------------------- LLM Models ----------------------------- //
|
|
|
|
model LLMCallTemplate {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
developmentPhase DevelopmentPhase
|
|
templateName String
|
|
fileHash String
|
|
systemPrompt String
|
|
userPrompt String
|
|
retryPrompt String
|
|
|
|
Uses LLMCallAttempt[]
|
|
}
|
|
|
|
enum DevelopmentPhase {
|
|
REQUIREMENTS
|
|
DEVELOPMENT
|
|
DEPLOYMENT
|
|
}
|
|
|
|
model LLMCallAttempt {
|
|
id String @id @default(dbgenerated("gen_random_uuid()"))
|
|
createdAt DateTime @default(now())
|
|
model String
|
|
completionTokens Int
|
|
promptTokens Int
|
|
totalTokens Int
|
|
attempt Int
|
|
prompt Json
|
|
response String
|
|
|
|
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String?
|
|
Application Application? @relation(fields: [applicationId], references: [id], onDelete: Cascade)
|
|
applicationId String?
|
|
LLMCallTemplate LLMCallTemplate? @relation(fields: [llmCallTemplateId], references: [id], onDelete: Cascade)
|
|
llmCallTemplateId String?
|
|
}
|