Request model for creating memories.
| 602 | |
| 603 | |
| 604 | class APIADDRequest(BaseRequest): |
| 605 | """Request model for creating memories.""" |
| 606 | |
| 607 | # ==== Basic identifiers ==== |
| 608 | user_id: str = Field(None, description="User ID") |
| 609 | session_id: str | None = Field( |
| 610 | None, |
| 611 | description="Session ID. If not provided, a default session will be used.", |
| 612 | ) |
| 613 | task_id: str | None = Field(None, description="Task ID for monitering async tasks") |
| 614 | manager_user_id: str | None = Field(None, description="Manager User ID") |
| 615 | project_id: str | None = Field(None, description="Project ID") |
| 616 | |
| 617 | # ==== Multi-cube writing ==== |
| 618 | writable_cube_ids: list[str] | None = Field( |
| 619 | None, description="List of cube IDs user can write for multi-cube add" |
| 620 | ) |
| 621 | |
| 622 | # ==== Async control ==== |
| 623 | async_mode: Literal["async", "sync"] = Field( |
| 624 | "async", |
| 625 | description=( |
| 626 | "Whether to add memory in async mode. " |
| 627 | "Use 'async' to enqueue background add (non-blocking), " |
| 628 | "or 'sync' to add memories in the current call. " |
| 629 | "Default: 'async'." |
| 630 | ), |
| 631 | ) |
| 632 | |
| 633 | mode: Literal["fast", "fine"] | None = Field( |
| 634 | None, |
| 635 | description=( |
| 636 | "(Internal) Add mode used only when async_mode='sync'. " |
| 637 | "If set to 'fast', the handler will use a fast add pipeline. " |
| 638 | "Ignored when async_mode='async'." |
| 639 | ), |
| 640 | ) |
| 641 | |
| 642 | # ==== Business tags & info ==== |
| 643 | custom_tags: list[str] | None = Field( |
| 644 | None, |
| 645 | description=( |
| 646 | "Custom tags for this add request, e.g. ['Travel', 'family']. " |
| 647 | "These tags can be used as filters in search." |
| 648 | ), |
| 649 | ) |
| 650 | |
| 651 | info: dict[str, Any] | None = Field( |
| 652 | None, |
| 653 | description=( |
| 654 | "Additional metadata for the add request. " |
| 655 | "All keys can be used as filters in search. " |
| 656 | "Example: " |
| 657 | "{'agent_id': 'xxxxxx', " |
| 658 | "'app_id': 'xxxx', " |
| 659 | "'source_type': 'web', " |
| 660 | "'source_url': 'https://www.baidu.com', " |
| 661 | "'source_content': '西湖是杭州最著名的景点'}." |