SurfSense/surfsense_backend/app/agents/chat/runtime/references/models.py
DESKTOP-RTLN3BA\$punk 9642d7ced0 feat: antropic model added fix & kb tooling fixes
- Updated main-agent middleware to clarify that both filesystem reads/writes and knowledge-base retrieval are handled by the `knowledge_base` subagent.
- Introduced `_forward_mention_pins` function to carry `@`-mention pins into subagent state.
- Revised system prompts to reflect the new retrieval method and ensure proper citation handling.
- Removed the `search_knowledge_base` tool and its related tests, consolidating functionality under the `task` tool.
- Enhanced documentation to guide usage of the new retrieval approach and citation practices.
2026-06-25 20:19:44 -07:00

73 lines
1.7 KiB
Python

"""Data shapes for resolved ``@``-references.
One type per kind so each carries exactly the fields it needs: documents and
folders have a path, connectors have a provider, chats have neither. ``kind`` is
a class-level discriminator used by the renderer and scope builder.
"""
from __future__ import annotations
from dataclasses import dataclass
from enum import StrEnum
from typing import ClassVar
class ReferenceKind(StrEnum):
"""What the user pointed at; the value is the label shown to the model."""
DOCUMENT = "document"
FOLDER = "folder"
CONNECTOR = "connector"
CHAT = "chat"
@dataclass(frozen=True)
class _Reference:
"""Identity shared by every reference kind."""
entity_id: int
label: str
@dataclass(frozen=True)
class DocumentReference(_Reference):
"""A referenced document, reachable by its virtual path."""
path: str
kind: ClassVar[ReferenceKind] = ReferenceKind.DOCUMENT
@dataclass(frozen=True)
class FolderReference(_Reference):
"""A referenced folder, reachable by its virtual path."""
path: str
kind: ClassVar[ReferenceKind] = ReferenceKind.FOLDER
@dataclass(frozen=True)
class ConnectorReference(_Reference):
"""A referenced connector account; ``provider`` is its type label."""
provider: str | None = None
kind: ClassVar[ReferenceKind] = ReferenceKind.CONNECTOR
@dataclass(frozen=True)
class ChatReference(_Reference):
"""A referenced chat thread; its turns are read on demand, not here."""
kind: ClassVar[ReferenceKind] = ReferenceKind.CHAT
Reference = DocumentReference | FolderReference | ConnectorReference | ChatReference
__all__ = [
"ChatReference",
"ConnectorReference",
"DocumentReference",
"FolderReference",
"Reference",
"ReferenceKind",
]