A Table
object corresponds to a Brainbase worker.
Initialize
You can either initialize a Table
from scratch, or using an already initialized Brainbase
object, both methods are shown below.
import {Brainbase, Table} from "brainbase-ai"
// From scratch
const table = Table(api_key="YOUR_API_KEY", table_id="TABLE_ID")
// From Brainbase
const row = bb.table(table_id="TABLE_ID")
Read
Loads the title
and features
of the table from the database.
import {Brainbase, Row} from "brainbase-ai"
table.read()
Insert
The Table
object provides an easy function to insert any file or data type natively supported by Brainbase. You can insert any of the following using the same function:
- Local file: Insert any supported local file by providing the local file path
- URL: Insert any remote file by providing the URL to the file. This also works for scraping the text content of non-file URLs.
- Dictionary: Insert a dictionary with the keys corresponding to the keys of the features of the
Table
object.
import {Brainbase, Row} from "brainbase-ai"
// Insert local file
table.insert(file_path="/sales-call-3.mp3")
// Insert URL
table.insert(url="https://openai.com/secret/how-to-build-agi.pdf")
// Insert dictionary
table.insert(data={"name": "Sam Altman", "title": "CEO", "company": "OpenAI"})
Add Columns
You can add new columns to the table using the add_columns
function.
import {Brainbase, Row} from "brainbase-ai"
table.add_columns(columns=[
{
"key": "email",
"name": "Email",
"description": "Email of the contact",
"type": "EMAIL"
}, {
"key": "summary",
"name": "Contact summary",
"description": "A 50 words or less summary of the contact's experience in sales",
"type": "LONG_TEXT"
}
])
Delete
import {Brainbase, Row} from "brainbase-ai"
row.delete()
Run Action
You can run a worker action on a selected row using the run
function. How to create Action
.
import {Brainbase, Row} from "brainbase-ai"
row.run(action)