Skip to content

Repository files navigation

px0 Examples

This repository contains examples demonstrating how to use px0. Each example directory showcases parallel implementations of prompt rendering across Go, TypeScript, and Python.

Repository Structure

Each example is organized into its own folder containing individual language implementations.

  • 01-hello-world/
    • main.go: The Go implementation.
    • main.ts: The TypeScript implementation.
    • main.py: The Python implementation.

Installation

Set up the local environment and install dependencies.

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
npm install
go mod download

Running the Examples

Execute the example code in each language directory using standard compiler and interpreter tools. Ensure your local px0 server is running, or configure the host and access token using environment variables.

1. Setup Environment Variables

Set these variables in a .env file at the root of the project. A .env.example template is provided.

cp .env.example .env

The supported environment variables are:

  • PX0_HOST: The URL of your px0 API instance (defaults to http://localhost:8000).
  • PX0_ACCESS_TOKEN: Your API access token.

Before executing the examples, make sure to load the environment variables into your shell:

set -a && source .env && set +a

2. Execution

Python Execution

Activate the virtual environment and run the Python implementation:

python 01-hello-world/main.py

TypeScript Execution

Execute the TypeScript implementation directly using ts-node:

npx ts-node 01-hello-world/main.ts

Go Execution

Run the Go implementation:

go run 01-hello-world/main.go

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages