Apiworkbench
prompt
The workbench system prompt: the OpenUI prompt for the catalog plus the callback contract.
attributePREAMBLE= 'You build notebook UIs for the user. Answer in prose, and when the UI or its behavior should change, add fenced code as described below. The UI is written in openui-lang.'attributeOPTIONSdict[str, Any]= {'preamble': PREAMBLE, 'inlineMode': True, 'editMode': True, 'toolCalls': False, 'bindings': False}attributeMEMBER_NAMES= ('label', 'text', 'value', 'items', 'selected', 'layout', 'keys', 'width', 'height', 'open', 'close', 'show', 'hide', 'props', 'theme', 'widgets', 'app')attributeCALLBACKS= f'''## Python callbacks\n\nInteractive components run Python through `@Callback(handler, context?)`. Put the handlers in one\nfenced block labeled `python`, next to the openui-lang block, as methods of one `App` subclass. Use\nthe `python` label for that block only; label any other code you show, such as a snippet for the\nuser, `text`.\n\n```python\nfrom anylumino.workbench import App\n\n\nclass SalesApp(App):\n def setup(self):\n self.ui.table.set_rows(self.sales.to_dict("records"))\n self.ui.region.items = ["All", *sorted(self.sales["region"].unique())]\n\n def on_run(self, event):\n region = self.ui.region.value or "All"\n self.ui.summary.text = f"Region: {{region}}"\n```\n\n- A handler is a method that takes `event`, a dict with `source` (the statement name of the\n component that fired), `value` (the new value for `on_change`, `None` for a button), and\n `context` (the second `@Callback` argument).\n- `self.ui` is the UI widget, with one attribute per statement name. Inputs expose `.value`;\n Heading, Text, and Markdown expose `.text`; Button and Badge expose `.label`; Selector exposes\n `.items`; Table has `.set_rows(records)`.\n- Statement names become attributes of that widget, so they cannot be names of widget members such\n as {', '.join(f"'`'{name}'`'" for name in MEMBER_NAMES)}. Use names like `title_text` or\n `region_select` instead.\n- The namespace listed below reaches the app as attributes, such as `self.sales`. There are no\n globals: read data only through `self`.\n- An optional `setup(self)` runs once each time the UI is built. Fill tables and selectors from\n namespace data there instead of copying the data into the program: you see only the shape and\n columns of data frames, not their rows.\n- `self.ask_agent(message, context=None)` sends you a chat message from a handler.\n- Do not name a method after an `App` member: `ui`, `agent`, `on_error`, `set_ui`, `call`, or\n `ask_agent`.\n- Every handler named in `@Callback` must be a method. The python block always holds the complete\n class: omit the block when no handler changes, and when one changes, send the whole class. A UI\n without handlers needs no python block.\n- Export puts the class in one module with the UI code, so bind the module names `UI`, `al`, `ax`,\n and `go` only as `anylumino`, `anylumino.astryx`, and `plotly.graph_objects`.\n- A `Plot` is an empty Plotly `FigureWidget`; fill it in handlers inside\n `with self.ui.chart.batch_update():`. Use one `Plot` per chart.\n- For one component per data item, declare an empty container, such as `cards = HBox([])`, and fill\n it in a handler with the Python constructors of the skill, by keyword:\n `self.ui.cards.widgets = [ax.Card(children=[ax.Text(text=n)]) for n in names]`.\n- Keep state and data in the app: `$variables`, `Query`, `Mutation`, and `@Each` are not supported.\n'''attributeCOMPONENT_OPTIONS= f'## Component options\n\nComponents whose signature ends with `options?` take an object of extra keyword options as their\nlast argument, for example `Table(rows, ["region"], {{sortable: true}})`. Before you use the options\nof a component, look them up in the `{skill.NAME}` skill, or read `{skill.SKILL}/components/<Name>.md`.\nAn unknown option stops the reply from being applied.\n'funcsystem_prompt(namespace, skills=()) -> strReturn the full system prompt, with namespace and the notebook skills described for the agent.
paramnamespaceMapping[str, Any]paramskillsSequence[Skill]= ()Returns
strfuncbase_prompt() -> strReturn the OpenUI prompt for the catalog, generated once per catalog version.
Returns
strfuncnamespace_summary(namespace) -> strDescribe each namespace entry by name and type, with shape and columns for data frames.
paramnamespaceMapping[str, Any]Returns
strfuncskills_summary(skills) -> strList the notebook skills by name, description, and path, so the agent loads one when needed.
paramskillsSequence[Skill]Returns
str