6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
121 lines
2.7 KiB
Python
121 lines
2.7 KiB
Python
from datetime import datetime
|
|
from typing import TypeVar
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
from app.db import DocumentType
|
|
|
|
from .chunks import ChunkRead
|
|
|
|
T = TypeVar("T")
|
|
|
|
|
|
class ExtensionDocumentMetadata(BaseModel):
|
|
BrowsingSessionId: str
|
|
VisitedWebPageURL: str
|
|
VisitedWebPageTitle: str
|
|
VisitedWebPageDateWithTimeInISOString: str
|
|
VisitedWebPageReffererURL: str
|
|
VisitedWebPageVisitDurationInMilliseconds: str
|
|
|
|
|
|
class ExtensionDocumentContent(BaseModel):
|
|
metadata: ExtensionDocumentMetadata
|
|
pageContent: str # noqa: N815
|
|
|
|
|
|
class DocumentBase(BaseModel):
|
|
document_type: DocumentType
|
|
content: (
|
|
list[ExtensionDocumentContent] | list[str] | str
|
|
) # Updated to allow string content
|
|
workspace_id: int
|
|
|
|
|
|
class DocumentsCreate(DocumentBase):
|
|
pass
|
|
|
|
|
|
class DocumentUpdate(DocumentBase):
|
|
pass
|
|
|
|
|
|
class DocumentStatusSchema(BaseModel):
|
|
"""Document processing status."""
|
|
|
|
state: str # "ready", "processing", "failed"
|
|
reason: str | None = None
|
|
|
|
|
|
class DocumentRead(BaseModel):
|
|
id: int
|
|
title: str
|
|
document_type: DocumentType
|
|
document_metadata: dict
|
|
content: str = ""
|
|
content_preview: str = ""
|
|
content_hash: str
|
|
unique_identifier_hash: str | None
|
|
created_at: datetime
|
|
updated_at: datetime | None
|
|
workspace_id: int
|
|
folder_id: int | None = None
|
|
created_by_id: UUID | None = None
|
|
created_by_name: str | None = None
|
|
created_by_email: str | None = None
|
|
status: DocumentStatusSchema | None = None
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class DocumentWithChunksRead(DocumentRead):
|
|
chunks: list[ChunkRead] = []
|
|
total_chunks: int = 0
|
|
chunk_start_index: int = 0
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class PaginatedResponse[T](BaseModel):
|
|
items: list[T]
|
|
total: int
|
|
page: int
|
|
page_size: int
|
|
has_more: bool
|
|
|
|
|
|
class DocumentTitleRead(BaseModel):
|
|
"""Lightweight document response for mention picker - only essential fields."""
|
|
|
|
id: int
|
|
title: str
|
|
document_type: DocumentType
|
|
folder_id: int | None = None
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class DocumentTitleSearchResponse(BaseModel):
|
|
"""Response for document title search - optimized for typeahead."""
|
|
|
|
items: list[DocumentTitleRead]
|
|
has_more: bool
|
|
|
|
|
|
class DocumentStatusItemRead(BaseModel):
|
|
"""Lightweight document status payload for batch status polling."""
|
|
|
|
id: int
|
|
title: str
|
|
document_type: DocumentType
|
|
status: DocumentStatusSchema
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class DocumentStatusBatchResponse(BaseModel):
|
|
"""Batch status response for a set of document IDs."""
|
|
|
|
items: list[DocumentStatusItemRead]
|