Connector calls, semantic rules, and DuckDB memory keep long runs stable, and stream retry stops chats from stalling. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
727 B
Python
25 lines
727 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import asdict, dataclass
|
|
from typing import Any, Dict, Literal, Optional
|
|
|
|
ResourceType = Literal["file", "datasource", "knowledge", "connector"]
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ResourceRef:
|
|
id: str
|
|
type: ResourceType
|
|
name: str = ""
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return asdict(self)
|
|
|
|
@classmethod
|
|
def from_dict(cls, data: Dict[str, Any]) -> "ResourceRef":
|
|
return cls(
|
|
id=str(data.get("id") or data.get("resource_id") or ""),
|
|
type=str(data.get("type") or data.get("resource_type") or "file"), # type: ignore[arg-type]
|
|
name=str(data.get("name") or data.get("resource_name") or ""),
|
|
)
|