> ## Documentation Index
> Fetch the complete documentation index at: https://ladygraph.io.vn/llms.txt
> Use this file to discover all available pages before exploring further.

# sources

> Biến cơ sở dữ liệu, tệp cấu hình và markdown thành các Tài liệu.

## `sources.auto`

Tìm tri thức trong bất kỳ tệp cấu hình nào, không cần viết quy tắc nào cho nó.

#### `AutoConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `keep_score` | `int` | `2` |
| `ambiguous_score` | `int` | `1` |
| `passage` | `Literal['entry', 'field']` | `'entry'` |
| `protected` | `Literal['skip', 'label']` | `'skip'` |
| `redact` | `list[Literal['email', 'phone']]` | `[]` |
| `judge_prose` | `bool` | `True` |
| `judge_min_words` | `int` | `12` |
| `declare` | `bool` | `True` |
| `rewrite` | `bool` | `False` |
| `types` | `dict[str, str]` | `{}` |
| `knowledge_names` | `list[str]` | `[]` |
| `system_names` | `list[str]` | `[]` |

#### `AutoFlattener`

Khởi tạo bằng `AutoFlattener(config: AutoConfig \| None = None, triage: 'FieldTriage \| None' = None)`.

| Phương thức | Làm gì |
| - | - |
| `flatten(self, scope: str, raw: Any) -> list[Record]` | — |
| `analyse(self, raw: Any, *, judge: bool) -> list[Entry]` | — |
| `explain(self, raw: Any) -> list[Entry]` | Điều gì sẽ xảy ra với mỗi lá, mà không hỏi mô hình nào. |

#### `Entry`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `path` | `tuple[str, ...]` | required |
| `leaves` | `list[Leaf]` | factory |
| `profile` | `bool` | `False` |
| `status` | `str` | `'ok'` |
| `id` | `str` | `''` |
| `title` | `str` | `''` |
| `kind` | `str` | `''` |
| `unit` | `str` | `''` |
| `label` | `str` | `''` |
| `declared_id` | `str` | `''` |

| Phương thức | Làm gì |
| - | - |
| `(property)` | — |

#### `Leaf`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `key` | `str` | required |
| `value` | `Any` | required |
| `kind` | `str` | `''` |
| `score` | `int` | `0` |
| `reasons` | `list[str]` | factory |
| `verdict` | `str` | `'drop'` |
| `note` | `str` | `''` |

#### `main`

```python theme={null}
main(argv: list[str] | None = None) -> None
```

#### `misses`

```python theme={null}
misses(entries: list[Entry]) -> list[tuple[Entry, Leaf]]
```

Các trường bị bỏ theo điểm số dù giá trị của chúng đọc như ngôn ngữ: những nơi một sự kiện thật có thể đã bị mất.

#### `report`

```python theme={null}
report(entries: list[Entry], show_all: bool = False) -> str
```

#### `report_misses`

```python theme={null}
report_misses(entries: list[Entry]) -> str
```

## `sources.combined`

Nhiều Source nuôi một phạm vi.

#### `CombinedSource`

Khởi tạo bằng `CombinedSource(*sources: Source)`.

| Phương thức | Làm gì |
| - | - |
| `manifest(self, scope: str, now: datetime.datetime) -> dict[str, DocVersion]` | — |
| `read(self, scope: str, unit: str) -> Document` | — |
| `next_boundary(self, scope: str, now: datetime.datetime) -> datetime.datetime \| None` | — |

## `sources.entities`

Các loại thực thể từ cấu hình nạp dữ liệu: mã, chữ viết tắt, hoặc bất cứ thứ gì một lần triển khai muốn đặt tên và giải thích.

#### `Answer`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `text` | `str` | required |
| `resolver` | `str` | required |
| `tier` | `str` | required |
| `at` | `Pointer` | required |

#### `Classes`

Một nhãn cho một mục, đọc từ phần đầu của một nhóm khóa: QT là một quy trình, QĐ là một quy chế.

| Trường | Kiểu | Mặc định |
| - | - | - |
| `from_` | `str` | required |
| `by_prefix` | `dict[str, str]` | required |

#### `ConceptRules`

Những mục từ điển nào trở thành khái niệm, chúng được đọc ra sao, và những liên kết nào tới các khái niệm của tài liệu được giữ lại.

| Trường | Kiểu | Mặc định |
| - | - | - |
| `type` | `str` | `'term'` |
| `relation` | `str` | `'REFERS_TO'` |
| `actor` | `str` | `'entities-config'` |
| `describe_resolved` | `str` | `'{meaning} ({code}).'` |
| `describe_unresolved` | `str` | `'{code}, no full name is written in the loaded documents.'` |
| `max_share` | `float` | `0.08` |
| `min_passages_unresolved` | `int` | `3` |
| `lowercase_words` | `int` | `3` |
| `evidence_per_document` | `int` | `3` |
| `max_links` | `int` | `4` |
| `heading_chars` | `int` | `120` |
| `max_codes_in_passage` | `int` | `4` |

#### `EntityConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `order` | `list[str]` | required |
| `kinds` | `dict[str, EntityKind]` | required |
| `concepts` | `ConceptRules \| None` | `None` |

#### `EntityEngine`

Khởi tạo bằng `EntityEngine(config: EntityConfig)`.

| Phương thức | Làm gì |
| - | - |
| `claimed(self, text: str) -> list[tuple[str, re.Match]]` | — |
| `key_of(self, kind: str, m: re.Match) -> tuple[str, ...]` | — |
| `mentions(self, doc: Document, passage) -> list[tuple[tuple[str, ...], Pointer]]` | Mọi thứ tìm thấy trong một đoạn, dưới dạng khóa của nó và nơi nó nằm. |
| `label_of(self, kind: str) -> str` | — |
| `build(self, documents: Iterable[Document]) -> Lexicon` | — |

#### `EntityKind`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `answer` | `Literal['title', 'expansion']` | required |
| `pattern` | `str` | required |
| `key` | `list[str]` | required |
| `label` | `str` | `''` |
| `concept` | `bool` | `True` |
| `classes` | `Classes \| None` | `None` |
| `title` | `TitleRules` | factory |
| `resolvers` | `list[Resolver]` | `[]` |

#### `Entry`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `kind` | `str` | required |
| `key` | `tuple[str, ...]` | required |
| `display` | `str` | required |
| `label` | `str` | `''` |
| `passages` | `int` | `0` |
| `documents` | `set[str]` | factory |
| `answers` | `list[Answer]` | factory |
| `mentions` | `list[Pointer]` | factory |
| `code` | `str` | `''` |

| Phương thức | Làm gì |
| - | - |
| `best(self) -> Answer \| None` | Câu trả lời của bộ phân giải đầu tiên, theo thứ tự cấu hình, đã đưa ra một câu trả lời. |
| `agree(self) -> bool` | Hai bộ phân giải trở lên đã trả lời và cách diễn đạt của chúng bắt đầu giống nhau. |

#### `Lexicon`

Khởi tạo bằng `Lexicon(entries: dict[tuple[str, ...], Entry], *, passages: int = 0, lowercase: collections.Counter \| None = None, expansions: frozenset[str] = frozenset())`.

| Phương thức | Làm gì |
| - | - |
| `eligible(self, entry: Entry, rules: ConceptRules) -> bool` | Mục này có đáng có một khái niệm không? |
| `of(self, kind: str) -> list[Entry]` | — |
| `get(self, kind: str, *key_parts: str) -> Entry \| None` | — |
| `unresolved(self, kind: str, min_passages: int = 1) -> list[Entry]` | — |

#### `Pointer`

Nơi một thứ được tìm thấy.

| Trường | Kiểu | Mặc định |
| - | - | - |
| `document` | `str` | required |
| `passage` | `str` | `''` |
| `start` | `int` | `-1` |
| `length` | `int` | `0` |
| `fingerprint` | `str` | `''` |

#### `Resolver`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `type` | `Literal['metadata', 'title', 'text', 'paren_initials']` | required |
| `code` | `str \| None` | `None` |
| `pattern` | `str \| None` | `None` |
| `check` | `Optional[Literal['initials']]` | `None` |
| `tier` | `str` | `''` |
| `in_sections` | `str \| None` | `None` |
| `skip_title_matching` | `str \| None` | `None` |
| `skip_words` | `list[str]` | `['cua', 'va', 'doi', 'voi', 'cho', 'tai', 'tu', 'den', 'la', 'the', 'of', 'for', 'and', 'hoac']` |

#### `TitleRules`

Một câu trả lời tốt trông như thế nào.

| Trường | Kiểu | Mặc định |
| - | - | - |
| `strip` | `list[Literal['numbers', 'extension', 'kinds']]` | `[]` |
| `min_words` | `int` | `1` |
| `reject` | `list[str]` | `[]` |

#### `expand`

```python theme={null}
expand(template: str, own: str, patterns: dict[str, str]) -> str
```

#### `expanded_patterns`

```python theme={null}
expanded_patterns(kinds: dict[str, EntityKind]) -> dict[str, str]
```

Mẫu của mỗi loại với \{other\_kind} được thay bằng chính mẫu của loại đó, theo phụ thuộc chứ không theo độ ưu tiên.

#### `fold`

```python theme={null}
fold(text: str) -> str
```

Dạng khóa của một văn bản: chữ thường, không dấu, không dấu phân cách.

#### `load_entities`

```python theme={null}
load_entities(path: pathlib.Path | str) -> EntityConfig | None
```

Phần `entities:` của ladygraph.yaml, hoặc None khi không có.

#### `main`

```python theme={null}
main(argv: list[str] | None = None) -> None
```

#### `report`

```python theme={null}
report(lexicon: Lexicon, config: EntityConfig, kind: str | None = None, unresolved: bool = False, frequent: int = 5) -> str
```

## `sources.factory`

Dựng các Source từ danh sách `sources:` của ladygraph.yaml.

#### `load_sources`

```python theme={null}
load_sources(path: pathlib.Path | str, decider: Decider | None = None) -> dict[str, Source]
```

Tên -> Source cho mọi mục có một bộ điều hợp.

## `sources.flatten`

Làm phẳng và chuẩn hóa đầu vào phi cấu trúc thành các Record, đầu vào chung của các nguồn JSON, pydantic và markdown.

#### `EntryFlattener`

Làm phẳng JSON đã phân tích (hoặc một mô hình pydantic đã kết xuất) theo các `EntryRule`.

Khởi tạo bằng `EntryFlattener(rules: list[EntryRule], triage: 'FieldTriage \| None' = None)`.

| Phương thức | Làm gì |
| - | - |
| `flatten(self, scope: str, raw: Any) -> list[Record]` | — |

#### `EntryRule`

Phần nào của một tài liệu có cấu trúc cần nạp, và cách đọc nó.

| Trường | Kiểu | Mặc định |
| - | - | - |
| `pointer` | `str` | required |
| `kind` | `str` | `''` |
| `id` | `str \| None` | `None` |
| `title` | `str \| None` | `None` |
| `where` | `dict[str, Any]` | `{}` |
| `words` | `list[str]` | `[]` |
| `declare` | `bool` | `False` |
| `rewrite` | `bool` | `False` |
| `concept_type` | `str` | `''` |
| `passage` | `Literal['field', 'entry']` | `'field'` |
| `fields` | `list[str] \| None` | `None` |
| `exclude` | `list[str]` | `[]` |
| `render` | `dict[str, Literal['text', 'dnf']]` | `{}` |
| `labels` | `dict[str, str]` | `{}` |
| `metadata` | `dict[str, str]` | `{}` |
| `access_labels` | `list[str]` | `[]` |
| `valid_from` | `str \| None` | `None` |
| `valid_until` | `str \| None` | `None` |

#### `FlatSource`

Một `Source` trên các Record.

Khởi tạo bằng `FlatSource(*, name: str, scheme: str, shape: Literal['assemble', 'decompose', 'map'], load: Callable[[str], typing.Any], flattener: Flattener, document_scheme: str \| None = None, scope: str \| None = None)`.

| Phương thức | Làm gì |
| - | - |
| `manifest(self, scope: str, now: datetime.datetime) -> dict[str, DocVersion]` | — |
| `read(self, scope: str, unit: str) -> Document` | — |
| `next_boundary(self, scope: str, now: datetime.datetime) -> datetime.datetime \| None` | — |

#### `Flattener`

Khởi tạo bằng `Flattener(*args, **kwargs)`.

| Phương thức | Làm gì |
| - | - |
| `flatten(self, scope: str, raw: Any) -> list[Record]` | Biến đầu vào thô của một phạm vi thành các Record. |

#### `Part`

Một đoạn của một Record.

| Trường | Kiểu | Mặc định |
| - | - | - |
| `anchor` | `str` | required |
| `text` | `str` | required |
| `section` | `str` | `''` |

#### `Record`

Một đơn vị thay đổi, đã làm phẳng.

| Trường | Kiểu | Mặc định |
| - | - | - |
| `unit` | `str` | required |
| `title` | `str` | required |
| `parts` | `list[Part]` | required |
| `metadata` | `dict[str, Any]` | factory |
| `access_labels` | `list[str]` | factory |
| `valid_from` | `date \| None` | `None` |
| `valid_until` | `date \| None` | `None` |
| `declared` | `Declared \| None` | `None` |
| `rewrite` | `bool` | `False` |

#### `as_date`

```python theme={null}
as_date(value: Any) -> datetime.date | None
```

#### `as_list`

```python theme={null}
as_list(value: Any) -> list[str]
```

#### `clean`

```python theme={null}
clean(value: Any) -> str
```

Một giá trị đơn dưới dạng văn bản thường.

#### `describe_markers`

```python theme={null}
describe_markers(clauses: Any) -> str
```

Các mệnh đề dấu hiệu dưới dạng một câu.

#### `is_blank`

```python theme={null}
is_blank(value: Any) -> bool
```

#### `lines_for`

```python theme={null}
lines_for(value: Any, label: str) -> list[str]
```

Cách hiển thị mặc định của một trường: các dòng `label: text`, các khóa lồng nhau được nối bằng dấu chấm.

#### `pointer_tokens`

```python theme={null}
pointer_tokens(pointer: str) -> list[str]
```

#### `walk`

```python theme={null}
walk(value: Any, tokens: list[str], so_far: tuple[str, ...] = ()) -> Iterator[tuple[tuple[str, ...], typing.Any]]
```

Mọi (đường dẫn cụ thể, giá trị) mà pointer tới được.

## `sources.json`

Nguồn JSON: cấu hình nghiệp vụ được giữ trong một tệp JSON (hoặc YAML), mỗi mục một Tài liệu (INTERFACE §7).

#### `JsonSource`

Khởi tạo bằng `JsonSource(config: JsonSourceConfig, base_dir: pathlib.Path \| None = None, decider: Decider \| None = None)`.

#### `JsonSourceConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `kind` | `Literal['json']` | `'json'` |
| `name` | `str` | required |
| `scheme` | `str` | required |
| `document_scheme` | `str \| None` | `None` |
| `shape` | `Literal['assemble', 'decompose', 'map']` | `'map'` |
| `scope` | `str \| None` | `None` |
| `path` | `str` | required |
| `rules` | `list[EntryRule]` | factory |
| `auto` | `AutoConfig \| None` | `None` |
| `triage` | `TriageConfig \| None` | `None` |

#### `TriageConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `cache` | `str` | required |
| `drop_threshold` | `float` | `0.7` |

#### `make_flattener`

```python theme={null}
make_flattener(config: JsonSourceConfig | typing.Any, triage: FieldTriage | None)
```

`auto` đọc bất kỳ tệp nào theo hình dạng của nó.

#### `make_triage`

```python theme={null}
make_triage(config: TriageConfig | None, base_dir: pathlib.Path | None, decider: Decider | None) -> FieldTriage | None
```

#### `read_structured`

```python theme={null}
read_structured(path: pathlib.Path) -> Any
```

Phân tích một tệp JSON hoặc YAML.

#### `resolve_path`

```python theme={null}
resolve_path(template: str, scope: str, base_dir: pathlib.Path | None) -> pathlib.Path
```

## `sources.markdown`

Nguồn markdown: tri thức được giữ dưới dạng các tệp markdown, mỗi phần một Tài liệu (INTERFACE §7, dạng `decompose`).

#### `MarkdownFile`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `path` | `str` | required |
| `text` | `str` | required |

#### `MarkdownFlattener`

Khởi tạo bằng `MarkdownFlattener(config: MarkdownSourceConfig)`.

| Phương thức | Làm gì |
| - | - |
| `flatten(self, scope: str, raw: list[MarkdownFile]) -> list[Record]` | — |

#### `MarkdownSource`

Khởi tạo bằng `MarkdownSource(config: MarkdownSourceConfig, base_dir: pathlib.Path \| None = None)`.

#### `MarkdownSourceConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `kind` | `Literal['markdown']` | `'markdown'` |
| `name` | `str` | required |
| `scheme` | `str` | required |
| `document_scheme` | `str \| None` | `None` |
| `shape` | `Literal['assemble', 'decompose', 'map']` | `'decompose'` |
| `scope` | `str \| None` | `None` |
| `path` | `str` | required |
| `split_level` | `int` | `2` |
| `target_chars` | `int` | `800` |
| `skip_status` | `list[str]` | `['draft', 'deprecated']` |
| `metadata` | `dict[str, str]` | `{}` |
| `chunking` | `ChunkingConfig \| None` | `None` |

#### `find_files`

```python theme={null}
find_files(template: str, scope: str, base_dir: pathlib.Path | None) -> list[MarkdownFile]
```

#### `split_front_matter`

```python theme={null}
split_front_matter(text: str, path: str) -> tuple[dict[str, typing.Any], str]
```

## `sources.plan`

Cho biết một lần cập nhật sẽ làm gì, mà không trích xuất hay ghi bất cứ thứ gì.

#### `main`

```python theme={null}
main(argv: list[str] | None = None) -> None
```

## `sources.pydantic`

Nguồn pydantic: cấu hình vốn đã nằm trong mã dưới dạng các mô hình pydantic (INTERFACE §7).

#### `PydanticSource`

Khởi tạo bằng `PydanticSource(config: PydanticSourceConfig, provider: Callable[[str], typing.Any] \| None = None, base_dir: pathlib.Path \| None = None, decider: Decider \| None = None)`.

#### `PydanticSourceConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `kind` | `Literal['pydantic']` | `'pydantic'` |
| `name` | `str` | required |
| `scheme` | `str` | required |
| `document_scheme` | `str \| None` | `None` |
| `shape` | `Literal['assemble', 'decompose', 'map']` | `'map'` |
| `scope` | `str \| None` | `None` |
| `provider` | `str` | required |
| `exclude_defaults` | `bool` | `False` |
| `rules` | `list[EntryRule]` | factory |
| `auto` | `AutoConfig \| None` | `None` |
| `triage` | `TriageConfig \| None` | `None` |

#### `dump`

```python theme={null}
dump(value: Any, *, exclude_defaults: bool = False) -> Any
```

Dữ liệu thường từ một mô hình, hoặc từ các dict và danh sách chứa các mô hình.

#### `import_provider`

```python theme={null}
import_provider(spec: str) -> Callable[[str], typing.Any]
```

## `sources.resolver`

Một Resolver đọc lại văn bản hiện tại qua một Source (INTERFACE mục 6, "Resolver").

#### `SourceResolver`

Khởi tạo bằng `SourceResolver(source: Source, *, max_workers: int = 4)`.

| Phương thức | Làm gì |
| - | - |
| `resolve_many(self, evidence: Sequence[Evidence], timeout_s: float, with_content: bool = False) -> dict[str, Resolution]` | Được đánh khóa theo mã bằng chứng. |

## `sources.signals`

Các tín hiệu xác định giúp phân biệt tri thức với cấu hình hệ thống, cho bất kỳ cấu hình nào ở bất kỳ miền nào.

#### `describe_clause`

```python theme={null}
describe_clause(clause: str) -> str
```

`a & b & !c` dưới dạng lời.

#### `effective_kind`

```python theme={null}
effective_kind(key: str, value: Any, extra_knowledge: tuple[str, ...] = (), extra_system: tuple[str, ...] = ()) -> str
```

`value_kind`, ngoại trừ các từ đơn dưới một tên nghiêng về tri thức là một bộ từ vựng: `["laptop", "invoice"]` dưới `aliases` là từ khóa, dưới `route_codes` là các từ mã.

#### `is_protected`

```python theme={null}
is_protected(key: str, value: Any) -> bool
```

Một trường đánh dấu mục của nó là bí mật hoặc riêng tư, chẳng hạn `kind: secret` hoặc `visibility: restricted`.

#### `key_words`

```python theme={null}
key_words(key: str) -> list[str]
```

#### `name_lean`

```python theme={null}
name_lean(key: str, extra_knowledge: tuple[str, ...] = (), extra_system: tuple[str, ...] = ()) -> int
```

+1 cho một tên trường gợi ý tri thức, -1 cho tên gợi ý cấu hình, 0 trong các trường hợp còn lại.

#### `normalized`

```python theme={null}
normalized(text: Any) -> str
```

#### `redact`

```python theme={null}
redact(text: str, kinds: tuple[str, ...] = ('email', 'phone')) -> str
```

Che thông tin liên hệ, cho một lần triển khai không được gửi chúng cho mô hình.

#### `score_leaf`

```python theme={null}
score_leaf(key: str, value: Any, *, refers: int = 0, extra_knowledge: tuple[str, ...] = (), extra_system: tuple[str, ...] = ()) -> tuple[int, list[str]]
```

Điểm của một lá và các lý do, bằng lời thường.

#### `value_kind`

```python theme={null}
value_kind(value: Any) -> str
```

Một trong: empty, flag, number, time, contact, address, token, tokens, word, phrase, sentence, vocab, objects, mixed.

## `sources.sql`

Nguồn SQL: dựng các Tài liệu từ các dòng của cơ sở dữ liệu (INTERFACE §7).

#### `ConnectionConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `dsn` | `str` | required |

#### `DocumentMap`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `title` | `str` | required |
| `metadata` | `dict[str, str]` | `{}` |
| `access_labels` | `list[str]` | `[]` |
| `valid_from` | `str \| None` | `None` |
| `valid_until` | `str \| None` | `None` |
| `version` | `VersionMap` | required |
| `passage` | `PassageMap` | required |

#### `Executor`

Khởi tạo bằng `Executor(*args, **kwargs)`.

| Phương thức | Làm gì |
| - | - |
| `run(self, connection: str, sql: str, params: dict[str, typing.Any]) -> list[dict[str, typing.Any]]` | — |

#### `PassageMap`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `text` | `str` | required |
| `anchor` | `str \| None` | `None` |
| `section` | `str \| None` | `None` |

#### `Queries`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `manifest` | `QueryConfig` | required |
| `document` | `QueryConfig` | required |
| `passages` | `QueryConfig \| None` | `None` |
| `passages_digest` | `QueryConfig \| None` | `None` |
| `replacements` | `QueryConfig \| None` | `None` |
| `get_scope` | `QueryConfig \| None` | `None` |

#### `QueryConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `sql` | `str` | required |
| `connection` | `str \| None` | `None` |

#### `Relationship`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `from_` | `str` | required |
| `to` | `str` | required |
| `cardinality` | `Literal['1:1', '1:N', 'N:M']` | required |
| `pick` | `Optional[Literal['latest']]` | `None` |
| `order_by` | `str \| None` | `None` |

#### `SqlAlchemyExecutor`

Khởi tạo bằng `SqlAlchemyExecutor(connections: dict[str, ConnectionConfig])`.

| Phương thức | Làm gì |
| - | - |
| `run(self, connection: str, sql: str, params: dict[str, typing.Any]) -> list[dict[str, typing.Any]]` | — |

#### `SqlSource`

Khởi tạo bằng `SqlSource(config: SqlSourceConfig, executor: Executor \| None = None)`.

| Phương thức | Làm gì |
| - | - |
| `manifest(self, scope: str, now: datetime.datetime) -> dict[str, DocVersion]` | Các đơn vị có hiệu lực và phiên bản của chúng. |
| `read(self, scope: str, unit: str) -> Document` | — |
| `next_boundary(self, scope: str, now: datetime.datetime) -> datetime.datetime \| None` | — |

#### `SqlSourceConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `kind` | `Literal['sql']` | `'sql'` |
| `name` | `str` | required |
| `scheme` | `str` | required |
| `document_scheme` | `str \| None` | `None` |
| `shape` | `Literal['assemble', 'decompose', 'map']` | required |
| `connections` | `dict[str, ConnectionConfig]` | required |
| `tables` | `dict[str, TableConfig]` | required |
| `relationships` | `list[Relationship]` | `[]` |
| `queries` | `Queries` | required |
| `map` | `DocumentMap` | required |
| `serves_from` | `str \| None` | `None` |

#### `TableConfig`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `connection` | `str` | required |
| `key` | `str \| list[str] \| None` | `None` |
| `columns` | `list[str]` | required |

#### `VersionMap`

| Trường | Kiểu | Mặc định |
| - | - | - |
| `file` | `list[str]` | required |
| `metadata` | `list[str]` | `[]` |

## `sources.triage`

Để một Decider đánh giá trường nào của một mục cấu hình là tri thức, để không ai phải liệt kê `exclude:` bằng tay.

#### `FieldTriage`

Khởi tạo bằng `FieldTriage(decider: Decider \| None, cache: pathlib.Path \| str, *, drop_threshold: float = 0.7)`.

| Phương thức | Làm gì |
| - | - |
| `keep(self, kind: str, field: str, value: Any) -> bool` | — |
| `keep_text(self, title: str, text: str) -> bool` | Văn bản dài này là tri thức, hay chỉ là một chỉ dẫn cho một trợ lý? |

#### `build_decider`

```python theme={null}
build_decider(name: str) -> Decider
```

#### `main`

```python theme={null}
main(argv: list[str] | None = None) -> None
```

#### `value_type`

```python theme={null}
value_type(value: Any) -> str
```

Một cụm từ tiếng Anh ổn định cho loại giá trị.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.