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>
60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
"""In-memory catalog models. Loaded from provider files, not from the network."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ConnectorFunction:
|
|
name: str
|
|
title: str
|
|
description: str
|
|
domain: str
|
|
effect: str
|
|
enabled: bool
|
|
method: str
|
|
path: str
|
|
input_schema: Dict[str, Any]
|
|
response_root: str
|
|
records_path: Optional[str] = None
|
|
summary_fields: List[str] = field(default_factory=list)
|
|
semantic_hints: List[str] = field(default_factory=list)
|
|
pagination: Optional[Dict[str, Any]] = None
|
|
content_type: str = "application/json"
|
|
timeout_seconds: int = 30
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NativeProvider:
|
|
id: str
|
|
version: str
|
|
display_name: str
|
|
category: str
|
|
base_url: str
|
|
auth_type: str
|
|
auth_parameter: str
|
|
credential_field: str
|
|
default_headers: Dict[str, str]
|
|
mode: str
|
|
health_function: str
|
|
health_body: Dict[str, Any]
|
|
aliases: Dict[str, List[str]]
|
|
guidance: str
|
|
functions: List[ConnectorFunction]
|
|
description: str = ""
|
|
|
|
def function(self, name: str) -> Optional[ConnectorFunction]:
|
|
for item in self.functions:
|
|
if item.name == name:
|
|
return item
|
|
return None
|
|
|
|
def enabled_reads(self) -> List[ConnectorFunction]:
|
|
return [
|
|
item
|
|
for item in self.functions
|
|
if item.enabled and item.effect == "read"
|
|
]
|