tdfs4ds.plugins¶
tdfs4ds.plugins
¶
What a plugin skill needs from tdfs4ds, as a public API (0.3.6.17).
A plugin skill is a folder of TDFS4DS_SKILLS_FOLDER holding a SKILL.md and a
skill.py that defines node(state). Code shared by several plugins goes in a
_lib folder next to them (from _lib.helpers import x); it is not listed as a skill.
- :func:
llm_json: a language-model call returning JSON, through whatever constraint the endpoint honours; - :func:
run_sql: a statement on the session's connection, as a frame, binary columns intact; - :func:
chart_payload: what a chart answer returns (:mod:tdfs4ds.plotting); - :func:
parse_period: the period a question names, with today read from the database clock.
chart_payload
¶
{"title", "html", "height"} for the chat (the shape MCP charts use).
llm_json
¶
llm_json(system_prompt: str, user_prompt: str, *, schema: Optional[dict] = None, expect=None, default=None, skill_name: str = 'plugin')
Ask the instruct model for JSON. Returns the parsed reply, else default (the failure is logged).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
Optional[dict]
|
JSON Schema of the reply, sent by the mechanism the endpoint honours
( |
None
|
expect
|
|
None
|
|
skill_name
|
str
|
the name in the logs and in the token count. |
'plugin'
|
run_sql
¶
Run a statement on the session's teradataml connection (one session: a volatile table created by one call is seen by the next) and return its rows as a frame.
Values are returned as the driver gives them, so a BYTE or BLOB column stays bytes. A
statement with no result set returns an empty frame. A database error raises. Not for a
background thread: teradataml shares one connection per process.
_bound
¶
A window bound as an aware datetime in zone. A date with no time covers its whole day and a
YYYY-MM its whole month, so an upper bound is the start of the next one (half-open).
parse_period
¶
The period question names: {"start", "end", "how"}, else None.
start and end are aware datetimes in timezone, half-open (end is excluded); None
when the question gives no such bound ("until March" has no start). how is dates (written
dates), relative ("last 7 days", "les 3 derniers mois") or day (today, yesterday). A date
written without an offset is read in timezone. "Now" and "today" come from the database clock
(now replaces it), so they agree with the data. A numeric range ("between 10 and 20") is no period.