### Quick Start Example Source: https://github.com/google/dotprompt/blob/main/docs/api/go/index.md A basic example demonstrating how to use the dotprompt package to render a template. ```APIDOC ## Quick Start Example ### Description A basic example demonstrating how to use the dotprompt package to render a template. ### Method ```go package main import ( "context" "fmt" "log" "github.com/google/dotprompt/go/dotprompt" ) func main() { source := ` --- model: gemini-pro input: schema: name: string --- Hello, {{name}}! ` dp := dotprompt.New() rendered, err := dp.Render(context.Background(), source, dotprompt.DataArgument{ Input: map[string]any{"name": "World"}, }) if err != nil { log.Fatal(err) } for _, msg := range rendered.Messages { fmt.Printf("%s: %v\n", msg.Role, msg.Content) } } ``` ``` -------------------------------- ### Start Development Server (Example) Source: https://github.com/google/dotprompt/blob/main/bazel/rules_flutter/README.md Example of starting a development server named 'dev' with a web port of 8080. ```python flutter_dev_server( name = "dev", web_port = 8080, ) ``` -------------------------------- ### Quick Start Source: https://github.com/google/dotprompt/blob/main/python/handlebarrz/README.md A basic example demonstrating how to create a template instance, register a template, and render it. ```python from handlebarrz import Template template = Template() template.register_template("greeting", "Hello, {{name}}!") result = template.render("greeting", {"name": "World"}) print(result) # Output: Hello, World! ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/google/dotprompt/blob/main/docs/contributing/index.md Starts a local web server to serve the project's documentation using MkDocs. Ensure 'uv' is installed and configured. ```shell uv run mkdocs serve ``` -------------------------------- ### Installation Source: https://github.com/google/dotprompt/blob/main/docs/api/go/index.md Install the dotprompt package using go get. ```APIDOC ## Installation ### Description Install the dotprompt package using go get. ### Method ```bash go get github.com/google/dotprompt/go/dotprompt ``` ``` -------------------------------- ### Run gRPC App Example Script Source: https://github.com/google/dotprompt/blob/main/bazel/rules_flutter/examples/grpc_app/README.md Use this script for quick setup, starting the server, and running the Flutter client. It automates common tasks for the gRPC app example. ```bash cd bazel/rules_flutter/examples/grpc_app # First time setup ./run.sh setup # Terminal 1: Start the gRPC server ./run.sh server # Terminal 2: Start the Flutter client ./run.sh client # Or run everything at once ./run.sh all ``` -------------------------------- ### Install Dotprompt Go Package Source: https://github.com/google/dotprompt/blob/main/docs/api/go/index.md Use 'go get' to install the Dotprompt Go package. ```bash go get github.com/google/dotprompt/go/dotprompt ``` -------------------------------- ### Navigate to example directory Source: https://github.com/google/dotprompt/blob/main/go/example/doc.md Change the current directory to the Go example directory. ```bash cd go/example ``` -------------------------------- ### Install Dotprompt Plugin with Packer Source: https://github.com/google/dotprompt/blob/main/packages/vim/README.md Installation method for Neovim using Packer. Requires calling the setup function. ```lua use { "google/dotprompt", config = function() require("dotprompt").setup() end, } ``` -------------------------------- ### Build and Test Examples (Unix) Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/GEMINI.md Shell script for building, testing, and running examples using Bazel on Unix-like systems. Ensure Bazel is installed and configured. ```bash #!/bin/bash set -euo pipefail bazel build //examples/hello_world:all bazel test //examples/hello_world:hello_test bazel run //examples/hello_world:hello_native ``` -------------------------------- ### Promptly CLI: Install from Prompt Store Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Install a specific Dotprompt package from the Prompt Store. Allows for versioned installation. ```bash # Install from Prompt Store promptly store install google/customer-support@1.0 ``` -------------------------------- ### Build and Run hello_world Example Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/examples/README.md Commands to build, test, and run the native binary for the hello_world example. ```bash cd hello_world bazel build //:hello_native # Native binary bazel test //:hello_test # Unit tests bazel run //:hello_native # Run the binary ``` -------------------------------- ### Install Dependencies with Promptly Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Install dependencies using Promptly's store install command, typically used in CI for reproducible builds. ```bash run: promptly store install --frozen ``` -------------------------------- ### Dotprompt Java API Quick Start Source: https://github.com/google/dotprompt/blob/main/docs/api/java/index.md A simple example demonstrating how to use the Dotprompt Java API to render a prompt. ```APIDOC ## Quick Start ```java import com.google.dotprompt.Dotprompt; import com.google.dotprompt.DotpromptOptions; import com.google.dotprompt.models.DataArgument; import com.google.dotprompt.models.RenderedPrompt; import java.util.Map; public class Example { public static void main(String[] args) { String source = """ --- model: gemini-pro input: schema: name: string --- Hello, {{name}}! """; Dotprompt dotprompt = new Dotprompt(); DataArgument data = DataArgument.builder() .input(Map.of("name", "World")) .build(); RenderedPrompt rendered = dotprompt.render(source, data, null); rendered.getMessages().forEach(message -> { System.out.printf("%s: %s%n", message.getRole(), message.getContent()); }); } } ``` ``` -------------------------------- ### Install Promptly from Source Source: https://github.com/google/dotprompt/blob/main/packages/vscode/README.md Install the 'promptly' CLI tool from source using Cargo. Requires Rust to be installed. ```bash cargo install --path rs/promptly ``` -------------------------------- ### Install Project Dependencies for CI/CD Source: https://github.com/google/dotprompt/blob/main/docs/contributing/index.md Installs project dependencies using the setup script with the 'ci' argument, suitable for CI/CD environments. ```bash scripts/setup -a ci ``` -------------------------------- ### Referencing Installed Packages in Dotprompt Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Examples show how to use installed packages, such as referencing partials or extending base configurations in Handlebars templates. ```handlebars {{!-- Reference a partial from an installed package --}} {{> @google/code-assistant/review-header}} {{!-- Use in frontmatter --}} --- extends: "@google/code-assistant/base-reviewer" --- ``` -------------------------------- ### Install Dotprompt CLI Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Install the Dotprompt CLI globally or as a project dependency. Usage examples show checking and formatting. ```bash # Global installation npm install -g @dotprompt/promptly # Project dependency npm install -D @dotprompt/promptly # Usage npx promptly check . npx promptly fmt --check ``` -------------------------------- ### Install @dotprompt/monaco and monaco-editor Source: https://github.com/google/dotprompt/blob/main/packages/monaco/README.md Install the necessary packages using npm or pnpm. ```bash npm install @dotprompt/monaco monaco-editor # or pnpm add @dotprompt/monaco monaco-editor ``` -------------------------------- ### Installation Source: https://github.com/google/dotprompt/blob/main/packages/monaco/README.md Install the `@dotprompt/monaco` package along with `monaco-editor`. ```APIDOC ## Installation ```bash npm install @dotprompt/monaco monaco-editor # or pnpm add @dotprompt/monaco monaco-editor ``` ``` -------------------------------- ### Check All Examples with Promptly CLI Source: https://github.com/google/dotprompt/blob/main/examples/README.md Use this command to check all example files in the ./examples directory for linting errors and warnings. ```bash scripts/promptly check ./examples ``` -------------------------------- ### Quick Start: Parse and Render a Dotprompt Source: https://github.com/google/dotprompt/blob/main/docs/api/python/dotpromptz.md Initialize the Dotprompt class, define a prompt source with model and input schema, and then render the prompt with provided data. This example demonstrates basic usage for prompt templating. ```python from dotpromptz import Dotprompt # Create a Dotprompt instance dp = Dotprompt() # Parse and render a prompt source = ''' --- model: gemini-pro input: schema: name: string --- Hello, {{name}}! ''' rendered = await dp.render(source, data={'input': {'name': 'World'}}) ``` -------------------------------- ### Install Promptly Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Use Cargo to install the Promptly toolchain. This command installs the executable globally. ```bash cargo install promptly ``` -------------------------------- ### Install Promptly CLI Source: https://github.com/google/dotprompt/blob/main/packages/promptly/README.md Install the Promptly CLI globally using npm, pnpm, or yarn. It can also be installed as a dev dependency. ```bash npm install -g @dotprompt/promptly ``` ```bash pnpm add -g @dotprompt/promptly ``` ```bash yarn global add @dotprompt/promptly ``` ```bash npm install -D @dotprompt/promptly ``` -------------------------------- ### Promptly CLI: Install Dependencies Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Install dependencies defined in the promptly.toml file for the current package. Can also install specific packages. ```bash # Install dependencies promptly install # Installs from promptly.toml promptly install google/prompts # Install a specific package ``` -------------------------------- ### Flutter Project Dependencies and Platform Setup Source: https://github.com/google/dotprompt/blob/main/bazel/rules_flutter/examples/grpc_app/README.md Install project dependencies and add platform support for a Flutter project. Run these commands in the project's root directory. ```bash cd bazel/rules_flutter/examples/grpc_app # Get dependencies flutter pub get # Add platform support (first time only) flutter create --platforms=web,macos,linux,windows,android,ios . ``` -------------------------------- ### Install @dotprompt/codemirror Source: https://github.com/google/dotprompt/blob/main/packages/codemirror/README.md Install the package using npm or pnpm. ```bash npm install @dotprompt/codemirror # or pnpm add @dotprompt/codemirror ``` -------------------------------- ### Configuration and Extensions Example Source: https://github.com/google/dotprompt/blob/main/docs/extending/specification.md An example test case demonstrating the use of frontmatter for configuration and extension fields within a template. ```yaml - name: ext template: | --- model: cool-model config: temperature: 3 ext1.foo: bar --- ``` -------------------------------- ### Install Promptly CLI Source: https://github.com/google/dotprompt/blob/main/packages/jetbrains/README.md Install the 'promptly' CLI tool using Cargo. This is required for LSP features. You can either install it directly or build it in release mode. ```bash cargo install --path rs/promptly ``` ```bash cargo build --release -p promptly ``` -------------------------------- ### Install Promptly for LSP Features Source: https://github.com/google/dotprompt/blob/main/packages/emacs/README.md Install the 'promptly' executable using cargo, required for LSP features. Provides two installation commands. ```bash cargo install --path rs/promptly # or cargo build --release -p promptly ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/google/dotprompt/blob/main/python/samples/streamlit-monaco-demo/README.md Create a virtual environment and install project dependencies using the 'uv' package manager. ```bash uv venv source .venv/bin/activate uv pip install -r requirements.txt ``` -------------------------------- ### Start Promptly LSP server Source: https://github.com/google/dotprompt/blob/main/packages/promptly/README.md Run the 'lsp' command to start the Language Server Protocol server for editor integration. ```bash promptly lsp ``` -------------------------------- ### Install VS Code Extension Source: https://github.com/google/dotprompt/blob/main/examples/README.md Run this script to install the Promptly extension for VS Code. ```bash ./scripts/install_vscode_ext ``` -------------------------------- ### Basic BUILD.bazel Example Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/README.md An example of a BUILD.bazel file demonstrating how to define Dart library, native binary, and test targets. ```APIDOC ## Create BUILD.bazel ```python load("@rules_dart//:defs.bzl", "dart_library", "dart_native_binary", "dart_test") dart_library( name = "mylib", srcs = glob(["lib/**/*.dart"]), pubspec = "pubspec.yaml", ) dart_native_binary( name = "app", main = "bin/main.dart", deps = [":mylib"], ) dart_test( name = "test", main = "test/mylib_test.dart", deps = [":mylib"], ) ``` ``` -------------------------------- ### Start Development Server (Command) Source: https://github.com/google/dotprompt/blob/main/bazel/rules_flutter/README.md Command to start the development server with hot reload using Bazel. ```bash bazel run //:dev ``` -------------------------------- ### Manual Installation of Dotprompt Emacs Mode Source: https://github.com/google/dotprompt/blob/main/packages/emacs/README.md Manual installation steps: copy the .el file to your load path and require it in your init file. ```elisp (add-to-list 'load-path "~/.emacs.d/lisp/") (require 'dotprompt-mode) ``` -------------------------------- ### Install Dotprompt Plugin with vim-plug Source: https://github.com/google/dotprompt/blob/main/packages/vim/README.md Installation method for Vim using vim-plug. Specifies the plugin path. ```vim Plug 'google/dotprompt', {'rtp': 'packages/vim'} ``` -------------------------------- ### Install Dotprompt Plugin with Vundle Source: https://github.com/google/dotprompt/blob/main/packages/vim/README.md Installation method for Vim using Vundle. Specifies the plugin path. ```vim Plugin 'google/dotprompt', {'rtp': 'packages/vim'} ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/google/dotprompt/blob/main/docs/contributing/index.md Installs the required tools and dependencies for the Dotprompt project from the repository's root directory. ```bash scripts/setup ``` -------------------------------- ### Dotprompt Java API Installation Source: https://github.com/google/dotprompt/blob/main/docs/api/java/index.md Instructions for installing the Dotprompt Java library using Maven and Gradle. ```APIDOC ## Installation ### Maven ```xml com.google.dotprompt dotprompt 0.1.0 ``` ### Gradle (Kotlin) ```kotlin implementation("com.google.dotprompt:dotprompt:0.1.0") ``` ### Gradle (Groovy) ```groovy implementation 'com.google.dotprompt:dotprompt:0.1.0' ``` ``` -------------------------------- ### Basic Bazel Commands for Examples Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/README.md Navigate to the examples/hello_world directory and use these Bazel commands to build, test, and run the native binary. ```bash cd examples/hello_world # Build everything bazel build //... # Run tests bazel test //... # Run the native binary bazel run //:hello_native ``` -------------------------------- ### Run Widget Tests (Example) Source: https://github.com/google/dotprompt/blob/main/bazel/rules_flutter/README.md Example of running widget tests named 'widget_tests' with dependencies from ':app_lib'. ```python flutter_test( name = "widget_tests", main = "test/widget_test.dart", deps = [":app_lib"], ) ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/google/dotprompt/blob/main/GEMINI.md Examples demonstrating the conventional commit format for various package scopes and commit types. ```bash # Feature in Python dotpromptz package feat(dotpromptz): add support for custom helpers # Bug fix in handlebarrz (Python Handlebars bindings) fix(dotpromptz-handlebars): correct template escaping behavior # Documentation for Go implementation docs(dotprompt-go): add usage examples to README # CI change for Rust ci(dotprompt-rs): add nightly toolchain testing # Cross-cutting change (no scope) chore: update dependencies across all packages ``` -------------------------------- ### ELI5 Example: What is a Worker? Source: https://github.com/google/dotprompt/blob/main/bazel/rules_flutter/GEMINI.md A concrete example of the ELI5 documentation format, explaining the concept of a 'Worker' using a LEGO analogy. ```markdown # ELI5 (Explain Like I'm 5) ## What is a Worker? Imagine you're building with LEGO. Without a worker, every time you want to build something, you have to get out the LEGO, build, then put it all away. A "worker" leaves the LEGO out so you can build faster! ``` -------------------------------- ### Build and run targets in hello_world example Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/CONTRIBUTING.md Navigate to the example directory and use Bazel commands to build all targets, run tests, or execute specific targets. ```bash cd examples/hello_world # Build all targets bazel build //... # Run tests bazel test //... # Run specific targets bazel run //:hello_native bazel run //:hello_pub_get ``` -------------------------------- ### Initialize Dotprompt Configuration Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Create a `promptly.toml` configuration file. Options include creating a minimal configuration or initializing a project intended for publishing as a package. ```bash promptly init ``` ```bash promptly init --minimal ``` ```bash promptly init --package ``` -------------------------------- ### Quick Start: Register and Render Template Source: https://github.com/google/dotprompt/blob/main/python/handlebarrz/README.md Demonstrates the basic usage of creating a Template instance, registering a template by name, and rendering it with context. ```python from handlebarrz import Template # Create a template instance template = Template() # Register and render a template template.register_template("greeting", "Hello, {{name}}!") result = template.render("greeting", {"name": "World"}) print(result) # Output: Hello, World! ``` -------------------------------- ### Dotprompt Configuration File Example Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Shows a sample `promptly.toml` configuration file, demonstrating how to set linting rules and formatter settings. ```toml # promptly.toml extends = "recommended" [rules] missing-partial = "error" # Missing partial unused-variable = "off" # Disable unused variable warning undefined-variable = "warn" # Undefined variable prefer-if-block = "off" # Disable suggestion [settings] max-template-lines = 200 max-partial-depth = 10 [ignore] patterns = ["**/fixtures/**", "**/tests/**"] ``` -------------------------------- ### Example Schema Inference Output Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md An example of the inferred schema output from 'promptly infer-schema --analyze' and the prompt to add it to the configuration file. ```bash $ promptly infer-schema greeting.prompt --analyze Analyzing variables in greeting.prompt... Inferred schema: { "name": "string", "items": "array", "items[].title": "string", "items[].description": "string?", "options": { "formal": "boolean?", "language": "string?" } } Add to promptly.toml? [Y/n] ``` -------------------------------- ### Example Global Configuration (TOML) Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Illustrates a typical global configuration file for Promptly, including settings for formatting, linting rules, LSP, and store preferences. Sensitive API keys should be managed separately. ```toml # ~/.config/promptly/promptly.toml # Default formatting preferences [format] indent = 2 line-ending = "lf" line-width = 100 # Default linting behavior [rules] strict = false max-warnings = 50 # LSP settings [lsp] model-registry-url = "https://store.dotprompt.dev/api/models" model-registry-sync-interval = "24h" inlay-hints = true show-token-counts = true # Store configuration [store] registry = "https://store.dotprompt.dev" # Token stored separately in credentials.toml for security # API keys (optional - can also use environment variables) [api-keys] # gemini = "..." # Prefer GEMINI_API_KEY env var # openai = "..." # Prefer OPENAI_API_KEY env var ``` -------------------------------- ### Bazel MODULE.bazel Configuration Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/examples/README.md Configuration for a new Bazel example project, including dependencies on rules_dart and Dart SDK setup. ```python module(name = "my_example", version = "0.1.0") bazel_dep(name = "rules_dart") local_path_override(module_name = "rules_dart", path = "../..") dart = use_extension("@rules_dart//:extensions.bzl", "dart") dart.configure(version = "3.7.0") use_repo(dart, "dart_sdk") ``` -------------------------------- ### Manual LSP Configuration with nvim-lspconfig Source: https://github.com/google/dotprompt/blob/main/packages/vim/README.md Manual setup for 'promptly' as an LSP server using nvim-lspconfig. Registers the server and configures keymaps for actions like formatting. ```lua local lspconfig = require("lspconfig") local configs = require("lspconfig.configs") -- Register promptly as an LSP server if not configs.promptly then configs.promptly = { default_config = { cmd = { "promptly", "lsp" }, filetypes = { "dotprompt" }, root_dir = lspconfig.util.find_git_ancestor, }, } end -- Start the server lspconfig.promptly.setup({ on_attach = function(client, bufnr) -- Enable formatting vim.keymap.set("n", "f", function() vim.lsp.buf.format({ async = true }) end, { buffer = bufnr }) end, }) ``` -------------------------------- ### Starlark-native Dependency Resolution Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/ROADMAP.md Example of using the dart_deps extension for Starlark-native dependency resolution from a pubspec.lock file. This replaces the older shell-based pub get mechanism. ```python # In MODULE.bazel dart_deps = use_extension("@rules_dart//:extensions.bzl", "dart_deps") dart_deps.from_pubspec_lock(lock_file = "//:pubspec.lock") use_repo(dart_deps, "dart_deps_http", "dart_deps_path", ...) ``` -------------------------------- ### Setup Bazel Action Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Sets up Bazel and Bazelisk for building the project. Enables caching for Bazel's disk and repository. ```yaml - name: Setup Bazel uses: bazel-contrib/setup-bazel@0.14.0 with: bazelisk-cache: true disk-cache: ${{ github.workflow }} repository-cache: true ``` -------------------------------- ### Python: Helper Function to Detect AWS Region Source: https://github.com/google/dotprompt/blob/main/docs/contributing/coding_guidelines.md For cloud services with regional endpoints, provide helper functions that auto-detect the region from environment variables instead of hardcoding a specific region. This example shows a helper that attempts to get the region from the environment. ```python def get_inference_profile_prefix(region: str | None = None) -> str: if region is None: region = os.environ.get('AWS_REGION') if region is None: raise ValueError('Region is required.') # Map region to prefix... ``` ```python def get_inference_profile_prefix(region: str = 'us-east-1') -> str: ... ``` -------------------------------- ### Install Dotprompt Plugin with lazy.nvim Source: https://github.com/google/dotprompt/blob/main/packages/vim/README.md Recommended installation method for Neovim using lazy.nvim. Includes optional configuration for 'promptly' path and enabling format on save. ```lua { "google/dotprompt", config = function() require("dotprompt").setup({ -- Optional: custom path to promptly binary promptly_path = "", -- Enable format on save format_on_save = true, }) end, } ``` -------------------------------- ### Install Dotprompt Emacs Mode with use-package Source: https://github.com/google/dotprompt/blob/main/packages/emacs/README.md Recommended installation method using use-package. Sets the load path, mode, and custom variables for promptly path and format on save. ```elisp (use-package dotprompt-mode :load-path "path/to/dotprompt/packages/emacs" :mode "\.prompt\'" :custom (dotprompt-promptly-path "promptly") (dotprompt-format-on-save t)) ``` -------------------------------- ### Install shell completions Source: https://github.com/google/dotprompt/blob/main/packages/promptly/README.md Use the 'completions install' command to install shell completion scripts for your current shell. ```bash promptly completions install ``` -------------------------------- ### Run Go Dotprompt example Source: https://github.com/google/dotprompt/blob/main/go/example/doc.md Execute the main Go program to process and render the prompt definition. ```bash go run main.go ``` -------------------------------- ### Install dotpromptz Package Source: https://github.com/google/dotprompt/blob/main/docs/api/python/dotpromptz.md Use pip to install the dotpromptz package. This command installs the latest version of the library and its dependencies. ```bash pip install dotpromptz ``` -------------------------------- ### Quick Start: Render a Dotprompt template Source: https://github.com/google/dotprompt/blob/main/docs/api/rust/index.md Demonstrates how to initialize Dotprompt, define a template with input schema, provide data, and render the prompt. ```rust use dotprompt::{Dotprompt, DataArgument, RenderedPrompt}; use serde_json::json; fn main() -> Result<(), Box> { let source = r#"--- model: gemini-pro input: schema: name: string --- Hello, {{name}}!"#; let dotprompt = Dotprompt::new(None); let mut data = DataArgument::default(); data.input = Some(json!({"name": "World"})); let rendered: RenderedPrompt = dotprompt.render(source, data, None)?; for message in &rendered.messages { println!("{:?}: {:?}", message.role, message.content); } Ok(()) } ``` -------------------------------- ### Quick Start: Render a Handlebars Template Source: https://github.com/google/dotprompt/blob/main/docs/api/python/handlebarrz.md Demonstrates how to create a Handlebars instance, register a template, and render it with provided data. Ensure the 'handlebarrz' library is imported. ```python from handlebarrz import Handlebars # Create a Handlebars instance hbs = Handlebars() # Register and render a template hbs.register_template('greeting', 'Hello, {{name}}!') result = hbs.render('greeting', {'name': 'World'}) print(result) # "Hello, World!" ``` -------------------------------- ### Install GitHub CLI on macOS Source: https://github.com/google/dotprompt/blob/main/docs/contributing/index.md Installs the GitHub CLI tool using Homebrew on macOS. Ensure Homebrew is installed first. ```bash brew install gh ``` -------------------------------- ### Example Configuration Merge (TOML and Bash) Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Demonstrates how configuration settings are merged, with project configuration overriding user configuration, and CLI flags overriding all other settings. Includes TOML snippets for user and project configs, and a bash snippet for CLI invocation. ```toml # ~/.config/promptly/config.toml (user) [format] indent = 4 ``` ```toml # ./promptly.toml (project) [format] indent = 2 # Overrides user config [rules] W001 = "off" ``` ```bash # CLI invocation promptly check --strict # Overrides everything ``` -------------------------------- ### Setup Promptly in GitHub Actions Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Use the google/promptly-action to set up the Promptly CLI in your GitHub Actions workflow. Specify the version if needed. ```yaml - name: Setup Promptly uses: google/promptly-action@v1 with: version: 'latest' ``` ```yaml - name: Setup Promptly uses: google/promptly-action@v1 ``` ```yaml - uses: google/promptly-action@v1 with: version: ${{ inputs.promptly-version }} ``` -------------------------------- ### Install Dependencies Source: https://github.com/google/dotprompt/blob/main/packages/vscode/README.md Install project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Promptly CLI: Initialize Package Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Initialize a new Dotprompt package in the current directory. This command sets up the basic structure for a prompt package. ```bash # Initialize a new package promptly init my-prompts ``` -------------------------------- ### Start Language Server Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Start the Language Server Protocol (LSP) server. It typically runs in the background, managed by editors. You can start it on standard input/output or a specified TCP port. ```bash promptly lsp ``` ```bash promptly lsp --tcp 8080 ``` -------------------------------- ### Install tree-sitter-dotprompt via npm Source: https://github.com/google/dotprompt/blob/main/packages/treesitter/README.md Use npm to install the tree-sitter-dotprompt package. ```bash npm install tree-sitter-dotprompt ``` -------------------------------- ### Setup gcloud CLI Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md Sets up the Google Cloud SDK for use in the workflow. ```yaml - name: Setup gcloud uses: google-github-actions/setup-gcloud@v2 ``` -------------------------------- ### Install Dotprompt Emacs Mode with straight.el Source: https://github.com/google/dotprompt/blob/main/packages/emacs/README.md Installation using straight.el, specifying the Git repository and files to include. Also configures the mode and format on save. ```elisp (straight-use-package '(dotprompt-mode :type git :host github :repo "google/dotprompt" :files ("packages/emacs/*.el"))) (use-package dotprompt-mode :mode "\.prompt\'" :custom (dotprompt-format-on-save t)) ``` -------------------------------- ### Install Dotprompt with npm Source: https://github.com/google/dotprompt/blob/main/js/README.md Install the dotprompt package using npm or pnpm. ```bash npm install dotprompt # or pnpm add dotprompt ``` -------------------------------- ### Build and Test Examples (Windows) Source: https://github.com/google/dotprompt/blob/main/bazel/rules_dart/GEMINI.md Batch script for building and testing examples using Bazel on Windows. It includes explicit error level checks for each Bazel command. ```batch :: scripts/test_examples.bat - Windows @echo off setlocal enabledelayedexpansion bazel build //examples/hello_world:all if %errorlevel% neq 0 exit /b %errorlevel% bazel test //examples/hello_world:hello_test if %errorlevel% neq 0 exit /b %errorlevel% ``` -------------------------------- ### Install dotprompt via yarn Source: https://github.com/google/dotprompt/blob/main/docs/api/typescript/index.md Install the dotprompt package using yarn. ```bash yarn add dotprompt ``` -------------------------------- ### Install dotprompt via pnpm Source: https://github.com/google/dotprompt/blob/main/docs/api/typescript/index.md Install the dotprompt package using pnpm. ```bash pnpm add dotprompt ``` -------------------------------- ### Install dotprompt via npm Source: https://github.com/google/dotprompt/blob/main/docs/api/typescript/index.md Install the dotprompt package using npm. ```bash npm install dotprompt ``` -------------------------------- ### Load Prompts from Filesystem Directory Source: https://github.com/google/dotprompt/blob/main/docs/api/go/index.md Initializes a DirStore to load Dotprompt templates from a specified directory. Requires context and a store options struct. ```go import "github.com/google/dotprompt/go/dotprompt" store := dotprompt.NewDirStore(dotprompt.DirStoreOptions{ Directory: "./prompts", }) prompt, err := store.Load(ctx, "greeting", nil) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Example Placeholder for API Endpoint Source: https://github.com/google/dotprompt/blob/main/docs/contributing/coding_guidelines.md In documentation and docstrings, use placeholder values that are clearly examples, not real values users might accidentally copy. This example shows a clear placeholder for an endpoint. ```plaintext endpoint='https://your-resource.openai.azure.com/' ``` ```plaintext endpoint='https://eastus.api.example.com/' ``` -------------------------------- ### Quick Start: Render a Dotprompt Template in Go Source: https://github.com/google/dotprompt/blob/main/docs/api/go/index.md Demonstrates how to use the Dotprompt Go API to render a simple template with dynamic data. Ensure the template source is correctly formatted. ```go package main import ( "context" "fmt" "log" "github.com/google/dotprompt/go/dotprompt" ) func main() { source := ` --- model: gemini-pro input: schema: name: string --- Hello, {{name}}! ` dp := dotprompt.New() rendered, err := dp.Render(context.Background(), source, dotprompt.DataArgument{ Input: map[string]any{"name": "World"}, }) if err != nil { log.Fatal(err) } for _, msg := range rendered.Messages { fmt.Printf("%s: %v\n", msg.Role, msg.Content) } } ``` -------------------------------- ### Metadata Example Source: https://github.com/google/dotprompt/blob/main/third_party/docsite/src/content/docs/reference/frontmatter.mdx An example of how to include custom metadata within the frontmatter, using a key-value structure. ```yaml metadata: customKey: customValue: 123 ``` -------------------------------- ### List Installed Packages Source: https://github.com/google/dotprompt/blob/main/docs/design/promptly.md View a list of packages installed in your project. You can also list outdated packages. ```bash promptly store list ``` ```bash promptly store list --outdated ``` -------------------------------- ### Install Dotprompt parser in Neovim Source: https://github.com/google/dotprompt/blob/main/packages/treesitter/README.md Use the :TSInstall command to install the Dotprompt parser after configuring nvim-treesitter. ```vim :TSInstall dotprompt ``` -------------------------------- ### Build tree-sitter-dotprompt from Source Source: https://github.com/google/dotprompt/blob/main/packages/treesitter/README.md Install dependencies and generate the parser from source code. ```bash cd packages/treesitter npm install npm run generate ```