Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt versioning #1138

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions agenta-backend/agenta_backend/models/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,9 @@ class Config:
collection = "bases"


class ConfigVersionDB(EmbeddedModel):
version: int
parameters: Dict[str, Any]
created_at: Optional[datetime] = Field(default=datetime.utcnow())
updated_at: Optional[datetime] = Field(default=datetime.utcnow())


class ConfigDB(Model):
config_name: str
current_version: int = Field(default=1)
parameters: Dict[str, Any] = Field(default=dict)
version_history: List[ConfigVersionDB] = Field(default=[])
created_at: Optional[datetime] = Field(default=datetime.utcnow())
updated_at: Optional[datetime] = Field(default=datetime.utcnow())

Expand All @@ -130,38 +121,51 @@ class Config:
class AppVariantDB(Model):
app: AppDB = Reference(key_name="app")
variant_name: str
image: ImageDB = Reference(key_name="image")
revision: int
image: ImageDB = Reference(key_name="image") # TODO: deprecated. remove
user: UserDB = Reference(key_name="user")
modified_by: UserDB = Reference(key_name="user")
organization: OrganizationDB = Reference(key_name="organization")
parameters: Dict[str, Any] = Field(default=dict) # TODO: deprecated. remove
previous_variant_name: Optional[str] # TODO: deprecated. remove
base_name: Optional[str]
base: VariantBaseDB = Reference(key_name="bases")
config_name: Optional[str]
config: ConfigDB = Reference(key_name="configs")
created_at: Optional[datetime] = Field(default=datetime.utcnow())
updated_at: Optional[datetime] = Field(default=datetime.utcnow())

is_deleted: bool = Field( # TODO: deprecated. remove
default=False
) # soft deletion for using the template variants

class Config:
collection = "app_variants"


class AppVariantRevisionsDB(Model):
variant: AppVariantDB = Reference(key_name="app_variants")
revision: int
modified_by: UserDB = Reference(key_name="user")
base: VariantBaseDB = Reference(key_name="bases")
config: ConfigDB = Reference(key_name="configs")
created_at: Optional[datetime] = Field(default=datetime.utcnow())
updated_at: Optional[datetime] = Field(default=datetime.utcnow())


class AppEnvironmentDB(Model):
app: AppDB = Reference(key_name="app")
name: str
revision: int
user: UserDB = Reference(key_name="user")
modified_by: UserDB = Reference(key_name="user")
organization: OrganizationDB = Reference(key_name="organization")
deployed_app_variant: Optional[ObjectId]
deployment: Optional[ObjectId] # reference to deployment
created_at: Optional[datetime] = Field(default=datetime.utcnow())
updated_at: Optional[datetime] = Field(default=datetime.utcnow())

class Config:
collection = "environments"

class AppEnvironmentRevisionDB(Model):
environment: AppEnvironmentDB = Reference(key_name="app_environment")
revision: int
modified_by: UserDB = Reference(key_name="user")
deployed_app_variant_revision: Optional[ObjectId] # reference to deployed app variant revision
deployment: Optional[ObjectId] # reference to deployment | TODO: where do we use this? how do we user this?
created_at: Optional[datetime] = Field(default=datetime.utcnow())


class TemplateDB(Model):
Expand Down
Loading