Documentation
¶
Overview ¶
Package assets persists multimodal asset lifecycle state.
Index ¶
- func BuildAttachmentBlock(items []Asset) string
- func WithAttachmentBlock(userText string, items []Asset) string
- type Asset
- type AudioProcessor
- type CreateRequest
- type DocumentIngestor
- type DocumentProcessor
- type ImageProcessor
- type Limits
- type Modality
- type PresignRequest
- type PresignResponse
- type Processor
- type ProcessorSet
- type Result
- type STTConfig
- type Scope
- type Service
- func (s *Service) Delete(ctx context.Context, identityID, assetID string) (Asset, error)
- func (s *Service) Finalize(ctx context.Context, identityID, assetID string) (Asset, error)
- func (s *Service) GetForIdentity(ctx context.Context, id, identityID string) (Asset, error)
- func (s *Service) IngestTelegramFile(ctx context.Context, req TelegramIngestRequest) (Asset, error)
- func (s *Service) ListForThread(ctx context.Context, identityID, threadID string) ([]Asset, error)
- func (s *Service) Presign(ctx context.Context, req PresignRequest) (PresignResponse, error)
- func (s *Service) Promote(ctx context.Context, identityID, assetID string) (Asset, error)
- func (s *Service) Retry(ctx context.Context, identityID, assetID string) (Asset, error)
- type SourceKind
- type Status
- type Store
- func (s *Store) Create(ctx context.Context, req CreateRequest) (Asset, error)
- func (s *Store) Delete(ctx context.Context, id, identityID string) (Asset, error)
- func (s *Store) GetForIdentity(ctx context.Context, id, identityID string) (Asset, error)
- func (s *Store) ListForThread(ctx context.Context, identityID, threadID string) ([]Asset, error)
- func (s *Store) MarkAccepted(ctx context.Context, id, identityID string, size int64, hash, mimeType string) (Asset, error)
- func (s *Store) MarkUploaded(ctx context.Context, id, identityID string, size int64, etag string) (Asset, error)
- func (s *Store) Promote(ctx context.Context, id, identityID string) (Asset, error)
- func (s *Store) SetResult(ctx context.Context, id, identityID string, result Result) (Asset, error)
- func (s *Store) SetStatus(ctx context.Context, id, identityID string, status Status, ...) (Asset, error)
- type StoreBackend
- type TelegramIngestRequest
- type VisionConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAttachmentBlock ¶
func WithAttachmentBlock ¶
Types ¶
type Asset ¶
type Asset struct {
ID string `json:"id"`
IdentityID string `json:"identity_id"`
SourceKind SourceKind `json:"source_kind"`
SourceRef string `json:"source_ref"`
ThreadID string `json:"thread_id"`
Scope Scope `json:"scope"`
Modality Modality `json:"modality"`
Status Status `json:"status"`
FileName string `json:"file_name"`
MIMEType string `json:"mime_type"`
DeclaredSizeBytes int64 `json:"declared_size_bytes"`
SizeBytes int64 `json:"size_bytes"`
ContentHash string `json:"content_hash"`
ObjectBucket string `json:"object_bucket"`
ObjectKey string `json:"object_key"`
ObjectETag string `json:"object_etag"`
DocumentID string `json:"document_id"`
Summary string `json:"summary"`
Metadata map[string]any `json:"metadata"`
ErrorCode string `json:"error_code"`
ErrorMessage string `json:"error_message"`
CreatedAt time.Time `json:"created_at,omitempty"`
UploadedAt time.Time `json:"uploaded_at,omitempty"`
AcceptedAt time.Time `json:"accepted_at,omitempty"`
ProcessedAt time.Time `json:"processed_at,omitempty"`
SearchableAt time.Time `json:"searchable_at,omitempty"`
CompletedAt time.Time `json:"completed_at,omitempty"`
DeletedAt time.Time `json:"deleted_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
Asset is the API-facing view of a persisted multimodal asset record.
type AudioProcessor ¶
type AudioProcessor struct {
Objects objectstore.Store
Config STTConfig
HTTPClient *http.Client
}
func NewAudioProcessor ¶
func NewAudioProcessor(objects objectstore.Store, cfg STTConfig) *AudioProcessor
func (*AudioProcessor) ProcessAsset ¶
type CreateRequest ¶
type CreateRequest struct {
IdentityID string
SourceKind SourceKind
SourceRef string
ThreadID string
Scope Scope
Modality Modality
FileName string
MIMEType string
DeclaredSizeBytes int64
ObjectBucket string
ObjectKey string
Metadata map[string]any
}
CreateRequest carries the fields needed to create a presigned asset record.
type DocumentIngestor ¶
type DocumentProcessor ¶
type DocumentProcessor struct {
Objects objectstore.Store
Ingest DocumentIngestor
}
func (*DocumentProcessor) ProcessAsset ¶
type ImageProcessor ¶
type ImageProcessor struct {
Objects objectstore.Store
Config VisionConfig
HTTPClient *http.Client
}
func NewImageProcessor ¶
func NewImageProcessor(objects objectstore.Store, cfg VisionConfig) *ImageProcessor
func (*ImageProcessor) ProcessAsset ¶
type Modality ¶
type Modality string
Modality describes the asset's content type class.
const ( ModalityDocument Modality = "document" ModalityImage Modality = "image" ModalityAudio Modality = "audio" ModalityUnknown Modality = "unknown" )
Supported asset modalities.
func InferModality ¶
type PresignRequest ¶
type PresignRequest struct {
IdentityID string `json:"identity_id"`
SourceKind SourceKind `json:"source_kind"`
ThreadID string `json:"thread_id"`
FileName string `json:"file_name"`
MIMEType string `json:"mime_type"`
DeclaredSizeBytes int64 `json:"size_bytes"`
ModalityHint Modality `json:"modality_hint"`
}
type PresignResponse ¶
type PresignResponse struct {
Asset Asset `json:"asset"`
Upload objectstore.PresignedPut `json:"upload"`
}
type ProcessorSet ¶
func (ProcessorSet) For ¶
func (p ProcessorSet) For(modality Modality) Processor
type Service ¶
type Service struct {
Store StoreBackend
Objects objectstore.Store
Processors ProcessorSet
Limits Limits
Bucket string
PresignTTL time.Duration
}
func (*Service) GetForIdentity ¶
func (*Service) IngestTelegramFile ¶
func (*Service) ListForThread ¶
func (*Service) Presign ¶
func (s *Service) Presign(ctx context.Context, req PresignRequest) (PresignResponse, error)
type SourceKind ¶
type SourceKind string
SourceKind identifies where an asset upload was initiated.
const ( SourceWeb SourceKind = "web" SourceTelegram SourceKind = "telegram" SourceCLI SourceKind = "cli" )
Supported asset source kinds.
type Status ¶
type Status string
Status is the durable lifecycle state for a multimodal asset.
const ( StatusCreated Status = "created" StatusPresigned Status = "presigned" StatusUploaded Status = "uploaded" StatusAccepted Status = "accepted" StatusProcessing Status = "processing" StatusSearchable Status = "searchable" StatusEmbedding Status = "embedding" StatusComplete Status = "complete" StatusFailed Status = "failed" StatusRefused Status = "refused" StatusDeleted Status = "deleted" StatusCanceled Status = "canceled" )
Asset lifecycle statuses.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists multimodal asset lifecycle state in Postgres.
func (*Store) GetForIdentity ¶
GetForIdentity returns a non-deleted asset by asset and identity id.
func (*Store) ListForThread ¶
ListForThread returns non-deleted assets in thread order.
func (*Store) MarkAccepted ¶
func (s *Store) MarkAccepted(ctx context.Context, id, identityID string, size int64, hash, mimeType string) (Asset, error)
MarkAccepted records validation of an uploaded asset.
func (*Store) MarkUploaded ¶
func (s *Store) MarkUploaded(ctx context.Context, id, identityID string, size int64, etag string) (Asset, error)
MarkUploaded records object storage upload completion.
type StoreBackend ¶
type StoreBackend interface {
Create(context.Context, CreateRequest) (Asset, error)
GetForIdentity(context.Context, string, string) (Asset, error)
ListForThread(context.Context, string, string) ([]Asset, error)
MarkUploaded(context.Context, string, string, int64, string) (Asset, error)
MarkAccepted(context.Context, string, string, int64, string, string) (Asset, error)
SetStatus(context.Context, string, string, Status, string, string) (Asset, error)
SetResult(context.Context, string, string, Result) (Asset, error)
Promote(context.Context, string, string) (Asset, error)
Delete(context.Context, string, string) (Asset, error)
}