"""Pydantic models for Mem.ai API request and response validation."""
from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, Field
class RequestResponse(BaseModel):
"""Standard response from Mem.ai API operations."""
request_id: str = Field(..., description="Unique identifier for the API request")
class MemItRequest(BaseModel):
"""Request model for Mem It intelligent content processing."""
input: str = Field(
...,
description="Content to save and process (text, HTML, markdown, etc.)",
min_length=1,
)
instructions: Optional[str] = Field(
None,
description="Optional processing instructions for how to handle the content",
)
context: Optional[str] = Field(
None,
description="Additional context about the content",
)
timestamp: Optional[datetime] = Field(
None,
description="Optional timestamp for when the content was created",
)
class NoteCreate(BaseModel):
"""Request model for creating a new note."""
content: str = Field(
...,
description="Markdown-formatted content of the note",
min_length=1,
)
id: Optional[UUID] = Field(
None,
description="Optional UUID for the note (auto-generated if not provided)",
)
collection_ids: Optional[list[UUID]] = Field(
None,
description="List of collection UUIDs to add this note to",
)
collection_titles: Optional[list[str]] = Field(
None,
description="List of collection titles to add this note to",
)
created_at: Optional[datetime] = Field(
None,
description="Optional creation timestamp",
)
updated_at: Optional[datetime] = Field(
None,
description="Optional last updated timestamp",
)
class Note(BaseModel):
"""Response model for a note."""
id: UUID = Field(..., description="Unique identifier for the note")
title: str = Field(..., description="Auto-generated or extracted title")
content: str = Field(..., description="Markdown-formatted content")
collection_ids: list[UUID] = Field(
default_factory=list,
description="Collections this note belongs to",
)
created_at: datetime = Field(..., description="When the note was created")
updated_at: datetime = Field(..., description="When the note was last updated")
request_id: Optional[str] = Field(
None,
description="Request ID from the API operation",
)
class CollectionCreate(BaseModel):
"""Request model for creating a new collection."""
title: str = Field(
...,
description="Title of the collection",
min_length=1,
)
id: Optional[UUID] = Field(
None,
description="Optional UUID for the collection (auto-generated if not provided)",
)
description: Optional[str] = Field(
None,
description="Optional markdown-formatted description",
)
created_at: Optional[datetime] = Field(
None,
description="Optional creation timestamp",
)
updated_at: Optional[datetime] = Field(
None,
description="Optional last updated timestamp",
)
class Collection(BaseModel):
"""Response model for a collection."""
id: UUID = Field(..., description="Unique identifier for the collection")
title: str = Field(..., description="Collection title")
description: Optional[str] = Field(
None,
description="Markdown-formatted description",
)
created_at: datetime = Field(..., description="When the collection was created")
updated_at: datetime = Field(
...,
description="When the collection was last updated",
)