Writing Scripts
Last updated
Last updated
Seal allows you to write and execute your own custom Python code within the platform, enabling powerful custom solutions and automations.
If this is your first time using Python, then there are great reference materials online such as: https://docs.python.org/3.10/tutorial/
What if I don't know how to code?
Not to worry - Seal comes with a built in AI Copilot to write code for you. Navigate to the 'Copilot' tab on the right hand side, and start chatting with the AI to describe what you need.
The AI agent has access to your current code, so you can ask it to help you debug specific issues or add to the existing code.
Once you're happy with the code, click on 'Accept code' to use it in your Script.
Note that the generated code may not fully be fit for your purpose - we recommend checking over the results.
The Seal module is a Python package for interacting programatically with the Seal platform.
It is automatically available in every Script's Python environment - you don't need to import it manually. The Seal module consists of a collection of methods on the seal
object:
Returns the entire json blob of data for that entity. The entity id can be copied from the entity's URL in Seal - it's the final section of the url, after the entity title.
Just passing an entity_id
returns the latest version or draft of the entity.
To get a specific version of an entity, include the version as a second argument.
Get entities by their title (string). Note that exact titles are necessary. Since multiple entities can share the same title, this returns an array.
The file is downloaded to the local filesystem of the virtual machine instance. The value returned is the local file path as a string.
Returns the id of the new File Entity in Seal
Parameters:
file_entity_id
: ID of the file entity to extract data from
version
: (Optional) Specific version of the file entity
prompt
: (Optional, keyword-only) Custom prompt to guide the data extraction
Returns: json
Example:
Seal comes with many common Python packages pre-installed. If there are other python packages you regularly require, please contact Seal support.
These packages are automatically imported in every Script, so don't need to be manually imported:
altair
(also aliased as alt
)
Chart
(alias of altair.Chart
)
pandas
(also aliased as pd
)
To temporarily install a package when running the script: