Use a table pipeline as a reusable function

Convert a table with computed columns into a callable function for multi-agent workflows and pipeline composition.

Agents · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

How it works

You wrap an entire table pipeline as a function. When you call this function from another table, it inserts a row into the agent table, runs all computed columns, and returns the specified output column.

What it covers

  • Create an "agent" table with computed columns
  • Convert the table to a callable UDF with pxt.udf(table, return_value=...)
  • Use the table UDF in other tables' computed columns

What it uses

Install
terminal
pip install pixeltable openai
Environment variables it names
OPENAI_API_KEY
Pixeltable calls
openai.chat_completions()pxt.create_table()pxt.udf()add_computed_column()insert()

A look at the code

pattern-table-as-udf.ipynb
# Add the LLM call as a computed column
summarizer.add_computed_column(
response=chat_completions(
messages=[
{
'role': 'user',
'content': 'Summarize this in one sentence:\n\n'
+ summarizer.text,
}
],
model='gpt-4o-mini',
)
)

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103