Documentation Index
Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
Use this file to discover all available pages before exploring further.
Problem
You have a table that runs a complex pipeline—LLM calls, tool use, post-processing—and you want to reuse that entire pipeline from other tables. Copy-pasting computed column definitions is error-prone and hard to maintain.Solution
What’s in this recipe:- 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
Setup
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘table_udf_demo’.
<pixeltable.catalog.dir.Dir at 0x17fd6e9d0>
Create an agent table with computed columns
You create a table that encapsulates a complete pipeline. This example builds a summarization agent:Created table ‘summarizer’.
Added 0 column values with 0 errors.
No rows affected.
Added 0 column values with 0 errors.
No rows affected.
Convert the table to a UDF
You usepxt.udf(table, return_value=...) to convert the table into a
callable function. The return_value specifies which column to return:
Use the table UDF in another table
You can now usesummarize() as a computed column in any other table:
Created table ‘articles’.
Added 0 column values with 0 errors.
No rows affected.
Inserting rows into `articles`: 2 rows [00:00, 196.58 rows/s]
Inserted 2 rows with 0 errors.
2 rows inserted, 6 values computed.
Explanation
How table UDFs work:Consumer table row → Table UDF called → Agent table inserts row →
Computed columns run → Return value extracted → Consumer gets result
When to use table UDFs vs @pxt.query:
Key benefits:
- Encapsulation: Hide complex pipeline details behind a simple function call
- Reusability: Use the same agent from multiple consumer tables
- Persistence: All intermediate results are stored in the agent table for debugging
- Composition: Chain agents together for multi-stage workflows
See also
- Look up structured
data -
Simple key-based lookups with
retrieval_udf - Build a RAG
pipeline -
Retrieval with
@pxt.query - Use tool calling with LLMs - Add tools to agent tables