#162 — Expose SQL query post-processing in LlmEngine so it is usable by facade
Repo: Twill-AI/twill-llm-engine State: closed | Status: done Assignee: meliascosta
Created: 2024-10-14 · Updated: 2024-11-26
Description
Caused by https://twill-network.slack.com/archives/C07QN069MED/p1728683058955949 (Martin, Luis, Aleksandr private).
In LlmEngine SQL post-processing happens not only for multi-series widgets but for widgets with forecasting and probably for ChatResponseTable. Also logic for pivoting data is much more complex then just calling pd.pivot()pd.pivot() - i.e. we need Pandas dependency for this anyway (pure Python “pivot” won’t be enough).
The easiest solution is to expose these “transformations” as public functions from LlmEngine and call them in Facade from there.
AC:
- LlmEngine contains new “transformations.py” module with contains functions-transformers which LlmEngine applies to SQL query output to convert it to widgets output converted to signature like
(data: List[Dict[str, Any]], headers: List[str])(i.e. just take what widget contains and which we got from SQL query). Also this module containsTRANSFORMERS: t.Dict[str, t.Callable[..]]dictionary with mapping of transformer functions to strings. If forecasting call is required then do it in “
Notes
Add implementation notes, blockers, and context here
Related
Add wikilinks to related people, meetings, or other tickets