Files
simbarag/blueprints/artifacts/models.py
T
ryan 0cf6229441 Add Artifact model and owner-scoped artifacts API
GET /api/artifacts?conversation_id= lists ArtifactRefs without data;
GET /api/artifacts/<id> returns the full artifact. Both 404 for other
users. create_artifact_from_output persists ToolArtifact dicts and drops
ones over 256 KB serialised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:53:22 -04:00

30 lines
1004 B
Python

from tortoise import fields
from tortoise.models import Model
class Artifact(Model):
"""A structured tool result (recipe, budget, note…) rendered in the artifact panel."""
id = fields.UUIDField(primary_key=True)
user = fields.ForeignKeyField("models.User", related_name="artifacts")
conversation = fields.ForeignKeyField(
"models.Conversation", related_name="artifacts", on_delete=fields.CASCADE
)
message = fields.ForeignKeyField(
"models.ConversationMessage",
related_name="artifacts",
null=True,
on_delete=fields.SET_NULL,
)
tool = fields.CharField(max_length=255)
kind = fields.CharField(max_length=64)
title = fields.CharField(max_length=255)
data = fields.JSONField()
source_ref = fields.JSONField(null=True)
version = fields.IntField(default=1)
created_at = fields.DatetimeField(auto_now_add=True)
updated_at = fields.DatetimeField(auto_now=True)
class Meta:
table = "artifacts"