Files
gpt-pilot/core/db/models/specification.py
Senko Rasic 5b474ccc1f merge gpt-pilot 0.2 codebase
This is a complete rewrite of the GPT Pilot core, from the ground
up, making the agentic architecture front and center, and also
fixing some long-standing problems with the database architecture
that weren't feasible to solve without breaking compatibility.

As the database structure and config file syntax have changed,
we have automatic imports for projects and current configs,
see the README.md file for details.

This also relicenses the project to FSL-1.1-MIT license.
2024-05-22 21:42:25 +02:00

49 lines
1.4 KiB
Python

from typing import TYPE_CHECKING, Optional
from sqlalchemy.orm import Mapped, mapped_column, relationship
from core.db.models import Base
if TYPE_CHECKING:
from core.db.models import ProjectState
class Complexity:
"""Estimate of the project or feature complexity."""
SIMPLE = "simple"
MODERATE = "moderate"
HARD = "hard"
class Specification(Base):
__tablename__ = "specifications"
# ID and parent FKs
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
# Attributes
description: Mapped[str] = mapped_column(default="")
architecture: Mapped[str] = mapped_column(default="")
system_dependencies: Mapped[list[dict]] = mapped_column(default=list)
package_dependencies: Mapped[list[dict]] = mapped_column(default=list)
template: Mapped[Optional[str]] = mapped_column()
complexity: Mapped[str] = mapped_column(server_default=Complexity.HARD)
# Relationships
project_states: Mapped[list["ProjectState"]] = relationship(back_populates="specification")
def clone(self) -> "Specification":
"""
Clone the specification.
"""
clone = Specification(
description=self.description,
architecture=self.architecture,
system_dependencies=self.system_dependencies,
package_dependencies=self.package_dependencies,
template=self.template,
complexity=self.complexity,
)
return clone