Overview

The generative.server Python package provides a Command Line Interface (CLI) that you can access through commands in the terminal. This CLI enables you to start a Function Server, a local server that allows the app to detect and interact with all the Generative Functions you’ve created.

When a Function Server is running, each Generative Function is accessible as an endpoint, allowing the app to communicate with and run these functions from your local machine.

Starting a Function Server

To start a Function Server, run the following command, depending on how you installed the generative-server package:

python -m generative.server start

Adblockers in browsers, and other networking security features, may cause issues accessing an endpoint for a Generative Function. Disabling the adblocker, or permitting in the adblocker the url that the Function Server is running on, can get around this. For example, if you’re using the Brave browser, you’ll need to disable the Shield blocker.

If you’re defining logic for your Generative Functions across multiple Python files, they must be organized as a Python package within your repository. You should then add an argument to the end of the command with relative path to the top-level of the Python package.

For example:

python -m generative.server start path/to/functions/package/

This command starts a local server from the specified folder, allowing the app to find and run your Generative Functions.

All inputs and outputs from Generative Functions run in the app are stored securely in the cloud.

If the Function Server starts successfully, you should see a link in the terminal to the port where it’s running (http://localhost:3000/ by default).

Clicking on this link will take you to the server’s API docs page, where advanced users can try evaluating their Generative Functions directly.

While this Function Server currently runs locally, it can be configured by advanced users to run remotely, allowing Generative Functions to be run in the cloud.

If you want to do this, please contact us.

Auto-reloading

When a change is detected in any of the files in the folder (or in any subfolders) that the Function Server is running from, the Function Server will be restarted so that the latest version of the Generative Function is always connected to the app.

Whilst the Function Server restarts, it will be unavailable from the app. If changes are made to any files scanned by the Function Server whilst an exploration is running from the app, then some designs will likely fail to generate.

Auto-reloading can be disabled by adding a --no-reload argument to the command to start the Function Server.

Arguments

Common optional arguments:

  • <folder-path>: The path to the folder containing your Generative Functions. Defaults to current folder.

  • --port <port-number>: Sets the port for the Function Server. Use this if the default port (3000) is occupied.

  • --reload, --no-reload: Enables or disables auto-reloading, which is on by default.

Additional options can be viewed by running:

python -m generative.server start --help