### Clone Tower Examples Repository Source: https://docs.tower.dev/docs/getting-started/quickstart-with-mcp Clones the official Tower examples repository from GitHub. This repository provides pre-built examples to help you get started and learn how Tower works. ```bash git clone https://github.com/tower/tower-examples ``` -------------------------------- ### Tower SDK Installation Source: https://context7_llms Instructions for installing the Tower SDK using pip. ```APIDOC ## Tower SDK Installation ### Description Installs the Tower SDK for Python. ### Method N/A (CLI Command) ### Command ```bash pip install tower ``` ### Usage Import the SDK in your Python code: ```python import tower ``` ``` -------------------------------- ### Towerfile Configuration Example Source: https://docs.tower.dev/docs/getting-started/quick-start An example Towerfile that defines an application's name, the script to execute, source files, and configurable parameters with descriptions and default values. ```yaml [app] name = "hello-world" script = "./task.py" source = [ "./task.py", ] [[parameters]] name = "friend" description = "Someone that is close to you." default = "Steve" [[parameters]] name = "foe" description = "Something that you'd prefer to avoid." default = "Carl" ``` -------------------------------- ### Install Tower Runner on Windows using MSI Source: https://context7_llms Installs the Tower Runner on Windows using the recommended MSI installer. It downloads the latest or a specific version for x64 or arm64 architectures, installs it silently, and configures the API key by editing the environment file. The service is then started and its status checked. ```powershell # Latest (x64) Invoke-WebRequest -Uri "https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/latest/tower-runner-x64.msi" -OutFile "tower-runner.msi" # Latest (arm64) Invoke-WebRequest -Uri "https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/latest/tower-runner-aarch64.msi" -OutFile "tower-runner.msi" # Versioned example (x64) Invoke-WebRequest -Uri "https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/0.8.17/tower-runner-x64-0.8.17.msi" -OutFile "tower-runner.msi" msiexec /i tower-runner.msi /qb notepad $env:ProgramData\tower-runner\tower-runner.env # Set TOWER_API_KEY Start-Service -Name TowerRunner Get-Service -Name TowerRunner ``` -------------------------------- ### Minimal Tower App: Hello World Source: https://context7_llms A basic Tower application that prints a greeting message. This example serves as a starting point for understanding Tower app structure and how to use parameters for runtime customization. ```python # This is a conceptual representation. Actual code would involve specific Tower API calls. # Example structure: # from tower import api # # def hello_world(name="World"): # print(f"Hello, {name}!") # # # Example of calling the app # api.run(hello_world) # Runs with default parameter "World" # api.run(hello_world, name="Tower") # Runs with custom parameter "Tower" ``` -------------------------------- ### Towerfile Example Configuration Source: https://docs.tower.dev/docs/reference/towerfile An example Towerfile demonstrating the structure for defining an application's name, main script, source files to be packaged, and optional parameters with their descriptions and default values. ```towerfile [app] name = "hello-world" script = "./task.py" source = [ "./.dlt/config.toml", "./**/*.py", "./*.py", "requirements.txt", "./_data/*", "./task.sh", "./dlt_project.yml" ] [[parameters]] name = "param1" description = "First parameter" default = "some value" [[parameters]] name = "param2" description = "Second parameter" default = "another value" ``` -------------------------------- ### Animation Configuration Example (Spring) Source: https://tower.dev/ An example of a spring animation configuration. This object defines the initial state, the animated state, and the transition properties, including type, stiffness, damping, and mass. ```json { "default": { "initial": { "opacity": 0.001, "rotate": 0, "rotateX": 0, "rotateY": 0, "scale": 1, "skewX": 0, "skewY": 0, "x": 0, "y": 166 }, "animate": { "opacity": 1, "rotate": 0, "rotateX": 0, "rotateY": 0, "scale": 1, "skewX": 0, "skewY": 0, "transition": { "damping": 30, "delay": 0, "mass": 1, "stiffness": 150, "type": "spring" }, "x": 0, "y": 0 } } } ``` -------------------------------- ### Download and Install Tower Runner (.deb) on Linux (Debian/Ubuntu) Source: https://context7_llms This snippet demonstrates how to download and install the Tower Runner using .deb packages on Debian/Ubuntu systems. It includes commands for both amd64 and arm64 architectures, fetching the latest version directly from S3. Ensure you have sudo privileges for the installation. ```bash # Latest (amd64) curl -L -O https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/latest/tower-runner_amd64.deb sudo dpkg -i tower-runner_amd64.deb # Latest (arm64) curl -L -O https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/latest/tower-runner_arm64.deb sudo dpkg -i tower-runner_arm64.deb ``` -------------------------------- ### Install Tower Runner on Windows using ZIP and PowerShell Source: https://context7_llms Installs the Tower Runner on Windows using a ZIP archive and PowerShell scripts as an alternative to the MSI installer. It downloads the latest or a specific version for x86_64 or arm64 architectures, extracts the contents, and runs an installation script. API key configuration and service management are then performed. ```powershell # Latest (x86_64) Invoke-WebRequest -Uri "https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/latest/tower-runner-windows-x86_64.zip" -OutFile "tower-runner.zip" # Latest (arm64) Invoke-WebRequest -Uri "https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/latest/tower-runner-windows-aarch64.zip" -OutFile "tower-runner.zip" # Versioned example (x86_64) Invoke-WebRequest -Uri "https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/0.8.17/tower-runner-windows-x86_64-0.8.17.zip" -OutFile "tower-runner.zip" Expand-Archive -Path "tower-runner.zip" -DestinationPath "C:\Program Files\tower-runner" cd "C:\Program Files\tower-runner" ./install-service.ps1 notepad $env:ProgramData\tower-runner\tower-runner.env # Set TOWER_API_KEY Start-Service -Name TowerRunner Get-Service -Name TowerRunner ``` -------------------------------- ### Animation Configuration Example (Tween) Source: https://tower.dev/ An example of a tween animation configuration. This object defines the initial and animated states, along with transition properties like duration, easing, and delay. ```json { "default": { "initial": { "opacity": 0.001, "rotate": 0, "rotateX": 0, "rotateY": 0, "scale": 0, "skewX": 0, "skewY": 0, "x": 0, "y": 0 }, "animate": { "opacity": 0, "rotate": 0, "rotateX": 0, "rotateY": 0, "scale": 0, "skewX": 0, "skewY": 0, "transition": { "delay": 0, "duration": 0.65, "ease": [ 0.44, 0, 0.56, 1 ], "type": "tween" }, "x": 0, "y": 0 } } } ``` -------------------------------- ### Install Tower Runner from Tarball on Linux (x86_64) Source: https://context7_llms Installs the Tower Runner on Linux systems by downloading and extracting a tarball. It fetches the latest or a specific version for x86_64 architecture, moves the binary to /usr/local/bin, and makes it executable. API key configuration and service management are handled separately. ```bash # Latest (x86_64) curl -L https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/latest/tower-runner-linux-x86_64.tar.gz | tar -xz # Specific version (x86_64) export RUNNER_VERSION=0.8.17 curl -L "https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/0.8.17/tower-runner-linux-x86_64-${RUNNER_VERSION}.tar.gz" | tar -xz sudo mv tower-runner /usr/local/bin/ sudo chmod +x /usr/local/bin/tower-runner ``` -------------------------------- ### Tower Query Example Source: https://tower.dev/ An example of a query structure used within the Tower platform, likely for data retrieval or pipeline configuration. It specifies a collection, limit, and fields to select. ```json {\"from\":\"598d23d8-4845-423a-8a7b-7456fd416fa3\",\"limit\":{\"type\":\"LiteralValue\",\"value\":10},\"select\":[{\"collection\":\"MWZshHscu\",\"name\":\"QWzqIOBdX\",\"type\":\"Identifier\"},{\"collection\":\"MWZshHscu\",\"name\":\"nyU13NNWt\",\"type\":\"Identifier\"},{\"collection\":\"MWZshHscu\",\"name\":\"DedjxqFun\",\"type\":\"Identifier\"},{\"collection\":\"MWZshHscu\",\"name\":\"EsE4EMfsN\",\"type\":\"Identifier\"},{\"collection\":\"MWZshHscu\",\"name\":\"Q2dmGx2xd\",\"type\":\"Identifier\"},{\"collection\":\"MWZshHscu\",\"name\":\"W2PtEc5Fk\",\"type\":\"Identifier\"},{\"collection\":\"MWZshHscu\",\"name\":\"Waggp_j1D\",\"type\":\"Identifier\"},{\"collection\":\"MWZshHscu\",\"name\":\"id\",\"type\":\"Identifier\"}]} ``` -------------------------------- ### Boot Featurebase SDK with Configuration (JavaScript) Source: https://tower.dev/ This snippet shows how to initialize the Featurebase SDK after it has been loaded. It includes essential configuration parameters such as appId and language. ```javascript Featurebase("boot", { appId: "6848324ec684148564484920", // required language: "en", // short code (e.g. "en", "de", etc.) // Add other config options as needed }); ``` -------------------------------- ### Example Towerfile Configuration Source: https://context7_llms This TOML snippet demonstrates the structure of a Towerfile, specifying application name, the main script to execute, and the source files to include in the deployment package. It's used by Tower to build and encrypt application packages. ```toml [app] name = "my-app" script = "./pipeline.py" source = [ "./**/*.py", "./*.py", "./requirements.txt" ] ``` -------------------------------- ### Install Tower Runner on Debian/Ubuntu (amd64) Source: https://context7_llms Installs the Tower Runner package on Debian-based systems for amd64 architecture. It downloads a .deb package, installs it using dpkg, and configures the API key via a systemd environment file. Finally, it enables and starts the tower-runner service. ```bash curl -L -O https://tower-packages.s3.us-east-1.amazonaws.com/releases/tower-runner/0.8.17/tower-runner_0.8.17-1_amd64.deb sudo dpkg -i tower-runner_0.8.17-1_amd64.deb sudo $EDITOR /etc/tower-runner/tower-runner.env # Set: TOWER_API_KEY=your-api-key-here sudo systemctl enable --now tower-runner sudo systemctl status tower-runner journalctl -u tower-runner -f ``` -------------------------------- ### POST /accounts/password-reset Source: https://context7_llms Starts the password reset process for an account. If an email address exists for the account supplied, you will get a reset password email. ```APIDOC ## POST /accounts/password-reset ### Description Starts the password reset process for an account. If an email address exists for the account supplied, you will get a reset password email. ### Method POST ### Endpoint /accounts/password-reset ### Parameters #### Query Parameters None #### Request Body - **email** (string) - Required - The email address to send the password reset email to ### Request Example ```json { "email": "user@example.com" } ``` ### Response #### Success Response (200) - **ok** (boolean) - A boolean indicating the request was successfully processed. #### Response Example ```json { "ok": true } ``` #### Error Response - **status** (integer) - HTTP status code - **type** (string) - A URI reference to human-readable documentation for the error. - **title** (string) - A short, human-readable summary of the problem type. - **detail** (string) - A human-readable explanation specific to this occurrence of the problem. - **instance** (string) - A URI reference that identifies the specific occurrence of the problem. - **errors** (array) - Optional list of individual error details - **location** (string) - Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id' - **message** (string) - Error message text - **value** (any) - The value at the given location ``` -------------------------------- ### Start Tower MCP Server with stdio Transport Source: https://docs.tower.dev/docs/reference/mcp-server Starts the Tower MCP server using the stdio transport mode. This is the recommended and simplest setup, suitable for most AI tools like Claude Code, as it does not require a background process. ```bash tower mcp-server --transport stdio ``` -------------------------------- ### GET /apps/{name}/runs/{seq}/logs Source: https://context7_llms Retrieves the logs associated with a particular run of an app. You can optionally filter logs by a start timestamp. ```APIDOC ## GET /apps/{name}/runs/{seq}/logs ### Description Retrieves the logs associated with a particular run of an app. ### Method GET ### Endpoint `/apps/{name}/runs/{seq}/logs` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the app to get logs for. - **seq** (integer) - Required - The sequence number of the run to get logs for. #### Query Parameters - **start_at** (string) - Optional - Fetch logs from this timestamp onwards (inclusive). Format: date-time. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **log_lines** (array) - An array of log line objects. - **run_id** (string) - The uuid of the Run. - **channel** (string) - The channel this log line belongs to. Enum: "program", "setup". - **reported_at** (string) - Timestamp of the log line. Format: date-time. - **line_num** (integer) - Line number. - **content** (string) - Contents of the log message. #### Response Example ```json { "log_lines": [ { "run_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "channel": "program", "reported_at": "2023-10-27T10:00:00Z", "line_num": 1, "content": "Starting execution..." } ] } ``` #### Error Response (404) - **title** (string) - A short, human-readable summary of the problem type. - **status** (integer) - HTTP status code. - **detail** (string) - A human-readable explanation specific to this occurrence of the problem. - **instance** (string) - A URI reference that identifies the specific occurrence of the problem. - **type** (string) - A URI reference to human-readable documentation for the error. - **errors** (array) - Optional list of individual error details. - **location** (string) - Where the error occurred. - **message** (string) - Error message text. - **value** (any) - The value at the given location. #### Error Response Example ```json { "title": "Not Found", "status": 404, "detail": "The requested resource was not found.", "instance": "https://example.com/error-log/xyz987", "type": "https://example.com/errors/not-found" } ``` ``` -------------------------------- ### Towerfile with Parameters Source: https://docs.tower.dev/docs/concepts/apps Configures an application with two runtime parameters: 'friend' and 'foe'. Each parameter has a name, description, and a default value, allowing for dynamic behavior at runtime. ```ini [app] name = "hello-world" script = "./task.py" source = [ "./task.py", ] [[parameters]] name = "friend" description = "Someone that is close to you." default = "Steve" [[parameters]] name = "foe" description = "Something that you'd prefer to avoid." default = "Carl" ``` -------------------------------- ### Run App Locally with Tower CLI Source: https://docs.tower.dev/docs/concepts/runs Executes an application in a local environment, mirroring the Tower cloud setup by installing dependencies and setting environment variables. This is useful for development and debugging. ```bash tower run --local ``` -------------------------------- ### GET /apps/{name} Source: https://context7_llms Retrieves details for a specific application by its name. You can also filter the runs associated with the app by specifying the number of recent runs, a start time, an end time, and a timezone. ```APIDOC ## GET /apps/{name} ### Description Retrieves details for a specific application by its name. You can also filter the runs associated with the app by specifying the number of recent runs, a start time, an end time, and a timezone. ### Method GET ### Endpoint /apps/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the app to fetch. #### Query Parameters - **runs** (integer) - Optional - The number of recent runs to fetch for the app. - **start_at** (string) - Optional - Filter runs scheduled after this datetime (inclusive). Provide timestamps in ISO-8601 format. - **end_at** (string) - Optional - Filter runs scheduled before or at this datetime (inclusive). Provide timestamps in ISO-8601 format. - **timezone** (string) - Optional - Timezone for the statistics (e.g., 'Europe/Berlin'). Defaults to UTC. ### Request Example ```json { "example": "No request body needed for this endpoint." } ``` ### Response #### Success Response (200) - **$schema** (string) - A URL to the JSON Schema for this object. - **app** (object) - Application details. - **created_at** (string) - The date and time this app was created. - **health_status** (string) - This property is deprecated. It will always be 'healthy'. - **is_externally_accessible** (boolean) - Indicates if the app is externally accessible. - **last_run** (object) - Deprecated: always null, previously latest run of this app. Use "runs" in app summary instead. - **name** (string) - The name of the app. - **runs** (array) - A list of runs for the app. - **number** (integer) - The run number. - **created_at** (string) - The date and time the run was created. - **ended_at** (string) - The date and time the run ended. - **environment** (string) - The environment the run was executed in. - **exit_code** (integer) - Exit code of the run, if the run is completed. Null if there is no exit code. - **initiator** (object) - Run initiator information. - **type** (string) - The type of initiator for this run. Null if none or unknown. - **details** (object) - Additional information about the initiator of a run. - **is_scheduled** (boolean) - Whether this run was triggered by a schedule (true) or on-demand (false). - **parameters** (object) - Parameters used to invoke this run. - **status** (string) - The status of the run. - **subdomain** (string) - The subdomain for the run. - **url** (string) - The URL for the run. - **version** (string) - The version of the app used for this run. - **slug** (string) - The slug of the app. - **updated_at** (string) - The date and time this app was last updated. #### Response Example ```json { "$schema": "https://api.tower.dev/v1/schemas/DescribeAppResponse.json", "app": { "created_at": "2023-10-27T10:00:00Z", "health_status": "healthy", "is_externally_accessible": true, "last_run": null, "name": "my-cool-app", "runs": [ { "number": 15, "created_at": "2023-10-27T10:05:00Z", "ended_at": "2023-10-27T10:10:00Z", "environment": "production", "exit_code": 0, "initiator": { "type": "tower_run", "details": { "run_app_name": "trigger-app", "run_number": 5 } }, "is_scheduled": false, "parameters": { "input_data": "some_value" }, "status": "succeeded", "subdomain": "my-cool-app-run-15", "url": "https://app.tower.dev/my-cool-app/runs/15", "version": "v1.2.0" } ], "slug": "my-cool-app", "updated_at": "2023-10-27T10:05:00Z" } } ``` ``` -------------------------------- ### Configure App Parameters with Tower CLI Source: https://context7_llms Demonstrates how to define and use parameters for Tower applications. Parameters allow for dynamic configuration of apps, with specified names, descriptions, and default values. These can be overridden when running the app from the command line. ```Towerfile [[parameters]] name = "iceberg_table" description = "The name of the input iceberg table" default = "invalid_table" [[parameters]] name = "AWS_REGION" description = "The region of S3 endpoint" default = "us-east-1" ``` ```bash tower run\ --parameter=AWS_REGION='eu-central-1'\ --parameter=iceberg_table='default.japan_trade_stats_2017_2020' ``` -------------------------------- ### Basic Python App Execution Source: https://docs.tower.dev/docs/concepts/apps Demonstrates a simple Python script that prints 'Hello, world!' multiple times with a delay. This script is intended to be executed by Tower. ```python import os import time count = 0 while count < 5: count += 1 print("Hello, world!") time.sleep(1) ``` -------------------------------- ### Python Application: Hello World Source: https://context7_llms A basic Python script that prints 'Hello, world!' to the console five times with a one-second delay between each print statement. This script serves as a simple example application. ```python import os import time count = 0 while count < 5: count += 1 print("Hello, world!") time.sleep(1) ``` -------------------------------- ### Get Tower Workflow Help Source: https://context7_llms Displays information about the recommended workflow for developing applications using the Tower service. This command provides guidance on the typical steps involved in the development lifecycle. ```bash tower workflow help ``` -------------------------------- ### Get Feature Flag Value Source: https://docs.tower.dev/docs/reference/api/run-app Gets the value of a feature flag. Retrieves the current state or value of a specific feature flag. ```APIDOC ## GET /feature-flags/:flag_name ### Description Gets the value of a feature flag. ### ``` -------------------------------- ### Install Tower CLI using pip Source: https://docs.tower.dev/docs/getting-started/quick-start Installs the latest version of the Tower command-line interface using pip. This is a prerequisite for interacting with the Tower system via the command line. ```bash pip install -U tower ``` -------------------------------- ### Analyze Ticker Data in Iceberg with LLM Source: https://context7_llms This example demonstrates reading historical ticker data from an Iceberg table, calculating moving averages and volatility using Polars, and then using DeepSeek R1 (via Hugging Face Hub) to generate buy/sell/hold recommendations. ```python # This is a conceptual representation. Actual code would involve specific library calls for Iceberg, Polars, and Hugging Face Hub. # Example structure: # import polars as pl # from pyiceberg.table import Table # from huggingface_hub import InferenceClient # # def analyze_ticker_data_with_llm(): # # Read data from Iceberg # table = Table.load('path/to/iceberg/table') # df = table.to_polars() # # # Calculate metrics using Polars # df = df.with_columns([ # pl.col('close').rolling_mean(window_size=7).alias('SMA_7'), # pl.col('close').rolling_mean(window_size=30).alias('SMA_30'), # # Calculate volatility ... # ]) # # # Prepare prompt for LLM # prompt = f"Analyze the following ticker data and provide buy/sell/hold recommendations:\n{df.tail(10)}" # # # Use LLM for recommendations # client = InferenceClient(model="deepseek-ai/deepseek-coder-1.3b-instruct") # Example model # recommendation = client.text_generation(prompt) # # # Store or display recommendation # print(recommendation) # # # Example of calling the app # # api.run(analyze_ticker_data_with_llm) ``` -------------------------------- ### Install Dependencies with uv sync Source: https://context7_llms This command installs project dependencies using the 'uv sync' command. It's typically used after cloning a project that utilizes uv for dependency management. ```bash uv sync ``` -------------------------------- ### Basic Towerfile Configuration Source: https://docs.tower.dev/docs/concepts/apps Defines a simple Tower application named 'hello-world', specifying the main script and the source files to be included. This Towerfile is used to package and run the Python app. ```ini [app] name = "hello-world" script = "./task.py" source = [ "./task.py", ] ``` -------------------------------- ### Install Tower CLI Source: https://docs.tower.dev/docs/getting-started/quickstart-with-mcp Installs the Tower Command Line Interface (CLI) using pip. This is a prerequisite for interacting with Tower services. ```bash pip install tower ``` -------------------------------- ### Create Apache Iceberg Table with Tower Source: https://context7_llms Demonstrates how to create an Apache Iceberg table using the Tower SDK. It requires defining a schema using pyarrow and specifying table creation methods. ```python import pyarrow as pa import tower SCHEMA = pa.schema([ ("col1", pa.string()), ("col2", pa.float64()), ... ]) mytable = tower.tables('mytable').create_if_not_exists(SCHEMA) ``` -------------------------------- ### Install Ollama for Local Inference (Bash) Source: https://docs.tower.dev/docs/using-tower/working-with-models Installs the Ollama package, which is recommended for local LLM inference during development. This command is executed in a bash terminal. ```bash pip install ollama ``` -------------------------------- ### Deploy Tower Apps in a Loop Source: https://context7_llms This script iterates through specified directories (ingest_*, run_*, customer_*, product_*) and deploys each Tower application using 'tower deploy'. It assumes you are in the root directory of the cloned repository. ```bash for app in ingest_* run_* customer_* product_*; do cd $app && tower deploy && cd .. done ``` -------------------------------- ### List Configured App Schedules (Bash) Source: https://context7_llms Lists all schedules that have been configured for apps within Tower. The output includes schedule ID, app name, environment, cron expression, and status. ```bash tower schedules list ``` -------------------------------- ### Towerfile Parameter Definition Example Source: https://docs.tower.dev/docs/reference/towerfile Illustrates how to define parameters within a Towerfile, including their name, a descriptive text, and a default value. This example shows two parameters: 'iceberg_table' and 'AWS_REGION'. ```towerfile [[parameters]] name = "iceberg_table" description = "The name of the input iceberg table" default = "invalid_table" [[parameters]] name = "AWS_REGION" description = "The region of S3 endpoint" default = "us-east-1" ``` -------------------------------- ### Schedule Tower App with Cron Source: https://context7_llms Demonstrates how to schedule a Tower app to run at a specific time using cron expressions via the Tower CLI. It shows basic scheduling and scheduling with custom parameters. ```bash tower schedules create --app=write-ticker-data-to-iceberg --cron="0 9 * * *" tower schedules create --app=write-ticker-data-to-iceberg --cron="0 9 * * *" \ --parameter=TICKERS="MSFT,AAPL,GOOGL" ``` -------------------------------- ### Get App Logs with Tower CLI Source: https://docs.tower.dev/docs/using-tower/test Fetch the logs for a specific run of your application using the 'tower apps logs' command. You need to provide the app name and the run number to get the relevant logs. ```shell tower apps logs # ``` -------------------------------- ### Create and Use Llm Instance for Chat and Prompt Source: https://docs.tower.dev/docs/reference/tower-sdk Demonstrates how to create an Llm instance using the llms factory function and then utilize it for both chat completions and simple prompt-based text generation. ```python import tower # Create an Llm instance (typically done via the llms() factory function) llm = tower.llms("llama3.2", max_tokens=1000) # Use for chat completions messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ] response = llm.complete_chat(messages) # Use for simple prompts response = llm.prompt("What is the capital of France?") ``` -------------------------------- ### GET /session API Endpoint Source: https://context7_llms This snippet defines the 'GET /session' API endpoint. It is used to validate the current session and retrieve user information. The endpoint expects no parameters and returns session details upon successful validation. ```javascript import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; import ParamsDetails from "@theme/ParamsDetails"; import RequestSchema from "@theme/RequestSchema"; import StatusCodes from "@theme/StatusCodes"; import OperationTabs from "@theme/OperationTabs"; import TabItem from "@theme/TabItem"; import Heading from "@theme/Heading"; Validate your current session and return the user information associated with the session. ``` -------------------------------- ### Example Shell Script for DLT Project Source: https://docs.tower.dev/docs/using-tower/develop An example of a shell script used within a Tower app to execute DLT (Data Load Tool) commands. This script defines a sequence of operations for data processing. ```shell dlt project cleandlt pipeline -ldlt pipeline events_to_lake rundlt transformation . rundlt dataset reports_dataset info ``` -------------------------------- ### POST /run_app Source: https://docs.tower.dev/docs/reference/tower-sdk Initiates a new run of a Tower application with specified parameters and environment. ```APIDOC ## POST /run_app ### Description Runs a Tower application with specified parameters and environment. This function initiates a new run of a Tower application identified by its slug. The run can be configured with an optional environment override and runtime parameters. If no environment is specified, the default environment from the Tower context is used. ### Method POST ### Endpoint /run_app ### Parameters #### Query Parameters - **slug** (str) - Required - The unique identifier of the application to run. - **environment** (str) - Optional - The environment to run the application in. If not provided, uses the default environment from the Tower context. #### Request Body - **parameters** (Dict[str, str]) - Optional - A dictionary of key-value pairs to pass as parameters to the application run. ### Request Example ```json { "slug": "my-app", "environment": "prod", "parameters": { "input_file": "data.csv", "output_dir": "results" } } ``` ### Response #### Success Response (200) - **Run** (object) - A Run object containing information about the initiated application run, including the app_slug and run number. #### Response Example ```json { "app_slug": "my-app", "run_number": 1 } ``` ### Errors - **RuntimeError**: If there is an error initiating the run or if the Tower API returns an error response. ```