tdfs4ds.agent.joinable_skill¶
tdfs4ds.agent.joinable_skill
¶
JOINABLE skill: which tables and views can a dataset (or an entity) be joined with (0.3.8.8).
"Which tables can I join with dataset X?" and "which tables can I join with X to study fiber loss?" are
answered by code from :func:tdfs4ds.dataset.joinable.joinable_objects_model: the objects documented in the
business dictionary or attached to the feature store that carry the entity's columns. Reads only, no
database scan beyond the candidates.
With a purpose ("fiber loss") the candidates are narrowed on their documentation, over all of them: a documentation pre-rank (the vector index and the words they share), then one model pass per batch of 150 that also names the relevant columns; every name is re-checked against the candidates. Without an instruct model only the pre-rank applies, and the answer says so. A second model call says what the retained objects' columns bring for the purpose, grounded only on the stored text.
The answer is written by code (EN/FR). The agent does not create the joined view: it points to the dataset
builder and tdfs4ds.create_joined_view.
_JOIN_WORD_RE
module-attribute
¶
_JOIN_WORD_RE = re.compile('\\b(join\\w*|combin\\w*|enrich\\w*|joindre|jointure\\w*|joint\\w*|associer|enrichir|rapprocher)\\b', re.IGNORECASE)
_POSSIBLE_RE
module-attribute
¶
_POSSIBLE_RE = re.compile('\\b(can|could|may|might|should|would|able|possible|joinable|to\\s+(?:join|combine|enrich)|puis-je|peut-on|peux|peut|pourrais|pourrait|possible|joindre|joignables?)\\b', re.IGNORECASE)
_NOT_THIS_RE
module-attribute
¶
_NOT_THIS_RE = re.compile("\\b(lineage|lign[ée]e|depend\\w*|upstream|downstream|reads?|built\\s+from|computed|come\\s+from|comes\\s+from|provien\\w*|d['’]o[uù]|source\\s+of)\\b", re.IGNORECASE)
_OBJECT_WORD_RE
module-attribute
¶
_CARRY_RE
module-attribute
¶
_CARRY_RE = re.compile('\\b(?:which|what|quel(?:le)?s?)\\s+(?:\\w+\\s+){0,2}(?:tables?|views?|vues?|objects?|objets?)\\s+(?:\\w+\\s+){0,2}(?:contain\\w*|have|has|hold\\w*|carry|carries|include\\w*|contiennent|contient|ont|poss[eè]dent|comporte\\w*)\\b', re.IGNORECASE)
_PURPOSE_VERB
module-attribute
¶
_PURPOSE_VERB = 'study(?:ing)?|analy[sz]e|analy[sz]ing|analyse|model(?:l?ing)?|predict(?:ing)?|understand(?:ing)?|investigat\\w+|forecast(?:ing)?|explain(?:ing)?|monitor(?:ing)?|detect(?:ing)?|[ée]tudier|analyser|mod[ée]liser|pr[ée]dire|comprendre|d[ée]tecter|expliquer|surveiller'
_PURPOSE_RES
module-attribute
¶
_PURPOSE_RES = [re.compile(f'\\b(?:to|in\\s+order\\s+to|for|pour|afin\\s+de)\\s+(?:{_PURPOSE_VERB})\\s+(?P<p>[^?.!]+)', re.IGNORECASE), re.compile('\\b(?:relevant\\s+to|related\\s+to|about|regarding|concerning|pertinentes?\\s+pour|li[ée]es?\\s+[àa]|concernant)\\s+(?P<p>[^?.!]+)', re.IGNORECASE)]
_FR_EXTRA_RE
module-attribute
¶
_FR_EXTRA_RE = re.compile('\\b(quelles?|puis-je|joindre|jointure\\w*|contiennent|contient|vues?)\\b', re.IGNORECASE)
_EXPLAIN_SCHEMA
module-attribute
¶
_EXPLAIN_SCHEMA = {'type': 'object', 'properties': {'objects': {'type': 'array', 'items': {'type': 'object', 'properties': {'object': {'type': 'string'}, 'adds': {'type': 'string'}, 'uses': {'type': 'array', 'items': {'type': 'string'}}}, 'required': ['object', 'adds', 'uses']}}}, 'required': ['objects']}
_NOTE_FR
module-attribute
¶
_NOTE_FR = {'No instruct model': "Aucun modèle n'est configuré : les objets sont classés selon les mots que leur documentation partage avec l'objectif, aucun n'est écarté.", 'The model could not be read': "La réponse du modèle n'a pas pu être lue pour une partie de la liste : ces objets sont gardés, classés selon les mots de leur documentation."}
joinable_request
¶
Does the question ask which tables / views a dataset or entity can be joined with? Pure.
A join word and an object word: yes ("which tables can I join with
extract_purpose
¶
The subject of the join named in the question ("to study fiber loss" -> "fiber loss"). Pure; None
when there is none. The classifier's purpose field is the first source; this is the fallback.
_resolve_target
¶
{"dataset": name} | {"entity": name} | {"ask": [candidates], "kind": ...} | {}.
_grounding
¶
The stored text the explanation may rest on: each object's description, sections and documented columns, and the dataset's own description and sections.
_explain_join
¶
{object upper: {"adds": str, "uses": [str]}} for the first max_detail rows, by one model call on
stored text only; names are re-checked. Empty on a failed call (the table stays).
_answer
¶
_answer(fr, target_label, entity, rows, purpose, pur_mode, pur_note, shown_cap, explain, errors, dataset_name) -> str
skill_joinable
¶
skill_joinable(question: str, object_name: Optional[str] = None, entity_name: Optional[str] = None, purpose: Optional[str] = None, *, inputs: Optional[dict] = None) -> dict
Which documented or attached tables and views can be joined with a dataset (or an entity)? A direct
answer (answer written by code, EN/FR) plus joinable_objects for the context graph.
purpose: the subject of the join ("fiber loss"); None = every candidate, ranked by match.