guidance Documentation

A guidance language for controlling large language models.

21,448 stars Jupyter Notebook 1 file ยท ~1,994 tokens
RAW Doc

1. Project Overview & Quickstart (guidance-ai/guidance)

File: docs/api.rst

.. currentmodule:: guidance

API Reference

This page contains the API reference for public objects and functions in Guidance.

.. _functions_api:

functions

.. autosummary::
:toctree: generated/

text
guidance.gen
guidance.select
guidance.json

.. _contexts_api:

context blocks

.. autosummary::
:toctree: generated/

text
guidance.instruction
guidance.system
guidance.user
guidance.assistant

.. _models_api:

models

.. autosummary::
:toctree: generated/

text
guidance.models.Model
guidance.models.Mock
guidance.models.LlamaCpp
guidance.models.Transformers
guidance.models.Anthropic
guidance.models.AzureOpenAI
guidance.models.Cohere
guidance.models.GoogleAI
guidance.models.LiteLLM
guidance.models.OpenAI
guidance.models.VertexAI

File: docs/api_examples.rst

.. currentmodule:: guidance

.. _api_examples:

API Examples

These examples parallel the namespace structure of Guidance. Each object or function in Guidance has a
corresponding example notebook here that demonstrates its API usage. The source notebooks
are available on GitHub <https://github.com/guidance-ai/guidance/tree/master/notebooks/api_examples>_.

.. _functions_examples:

functions

.. Examples for built-in guidance functions.

.. toctree::
:glob:
:maxdepth: 1

text
example_notebooks/api_examples/library/*

.. _models_examples:

models

.. Examples for members of :ref:guidance.models <models_api>.

.. toctree::
:glob:
:maxdepth: 1

text
example_notebooks/api_examples/models/*

File: docs/art_of_prompt_design.rst

.. currentmodule:: guidance

.. _art_of_prompt_design:

The Art of Prompt Design

These notebooks demonstrate how to design effective prompts and guidance programs, they also cover common useful
design patterns. The source notebooks are available on GitHub <https://github.com/guidance-ai/guidance/tree/master/notebooks/art_of_prompt_design>_.

.. toctree::
:glob:
:maxdepth: 1

text
example_notebooks/art_of_prompt_design/use_clear_syntax.ipynb
example_notebooks/art_of_prompt_design/prompt_boundaries_and_token_healing.ipynb
example_notebooks/art_of_prompt_design/tool_use.ipynb
example_notebooks/art_of_prompt_design/react.ipynb
example_notebooks/art_of_prompt_design/rag.ipynb

File: docs/index.rst

.. image:: figures/guidance_logo_blue.svg
:width: 300px
:align: center
|

Guidance enables you to control modern language models more effectively and efficiently than traditional prompting or chaining. Guidance programs allow you to interleave generation, prompting, and logical control into a single continuous flow matching how the language model actually processes the text.

Install

Guidance can be installed from PyPI <https://pypi.org/project/guidance>_::

pip install guidance

Contents

.. toctree::
:maxdepth: 2

Tutorials
API reference
API examples
The Art of Prompt Design


File: docs/tutorials.rst

.. currentmodule:: guidance

.. _tutorials:

Tutorials

These notebooks demonstrate various features of guidance``. The source notebooks are available on GitHub https://github.com/guidance-ai/guidance/tree/master/notebooks/api_examples`_.

.. toctree::
:glob:
:maxdepth: 1

text
example_notebooks/tutorials/intro_to_guidance.ipynb
example_notebooks/tutorials/token_healing.ipynb
example_notebooks/tutorials/regex_constraints.ipynb
example_notebooks/tutorials/guidance_acceleration.ipynb
example_notebooks/tutorials/code_generation.ipynb
example_notebooks/tutorials/chat.ipynb

File: guidance/models/broken_models/README.MD

These model files use an older version of guidance's internal API design, and need to be updated. They're kept here commented in the codebase solely as reference documentation to help with the migration. They cannot and should not be imported from this repository.


File: packages/python/stitch/docs/source/examples/index.rst

Examples

This section contains several examples generated from Jupyter notebooks.
The widgets have been embedded into the page for demonstrative purposes.

.. todo::

text
Add links to notebooks in examples folder similar to the initial
one. This is a manual step to ensure only those examples that
are suited for inclusion are used.

.. toctree::
:glob:

text
*

File: packages/python/stitch/docs/source/develop-install.rst

Developer install

To install a developer version of stitch, you will first need to clone
the repository::

text
git clone https://github.com/guidance-ai/stitch
cd stitch

Next, install it with a develop install using pip::

text
pip install -e .

If you are planning on working on the JS/frontend code, you should also do
a link installation of the extension::

text
jupyter nbextension install [--sys-prefix / --user / --system] --symlink --py stitch

jupyter nbextension enable [--sys-prefix / --user / --system] --py stitch

with the appropriate flag_. Or, if you are using Jupyterlab::

text
jupyter labextension install .

.. links

.. _appropriate flag: https://jupyter-notebook.readthedocs.io/en/stable/extending/frontend_extensions.html#installing-and-enabling-extensions


File: packages/python/stitch/docs/source/index.rst

stitch

Version: |release|

Bidirectional comms for Jupyter and JavaScript.

Quickstart

To get started with stitch, install with pip::

text
pip install stitch

or with conda::

text
conda install stitch

Contents

.. toctree::
:maxdepth: 2
:caption: Installation and usage

installing
introduction

.. toctree::
:maxdepth: 1

examples/index

.. toctree::
:maxdepth: 2
:caption: Development

develop-install

.. links

.. _Jupyter widgets: https://jupyter.org/widgets.html

.. _notebook: https://jupyter-notebook.readthedocs.io/en/latest/

2. Official Technical Reference & Guides (guidance-ai/guidance-ai.github.io)

Guidance Website

Guidance uses Astro for static site generation. Below is general structure and development instructions that is boilerplated with Astro.

๐Ÿš€ Project Structure

Inside of your Astro project, you'll see the following folders and files:

text
/
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ favicon.svg
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ””โ”€โ”€ Card.astro
โ”‚   โ”œโ”€โ”€ layouts/
โ”‚   โ”‚   โ””โ”€โ”€ Layout.astro
โ”‚   โ””โ”€โ”€ pages/
โ”‚       โ””โ”€โ”€ index.astro
โ””โ”€โ”€ package.json

Astro looks for .astro or .md files in the src/pages/ directory. Each page is exposed as a route based on its file name.

There's nothing special about src/components/, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.

Any static assets, like images, can be placed in the public/ directory.

๐Ÿงž Commands

All commands are run from the root of the project, from a terminal:

Command Action
npm install Installs dependencies
npm run dev Starts local dev server at localhost:4321
npm run build Build your production site to ./dist/
npm run preview Preview your build locally, before deploying
npm run astro ... Run CLI commands like astro add, astro check
npm run astro -- --help Get help using the Astro CLI

๐Ÿ‘€ Want to learn more?

Feel free to check our documentation or jump into our Discord server.