A tool for executing natural language recipe-like instructions
Project description
Recipe Tool
A tool for executing recipe-like natural language instructions to create complex workflows. This project includes a recipe executor and a recipe creator, both of which can be used to automate tasks and generate new recipes.
NOTE This project is a very early, experimental project that is being explored in the open. There is no support offered and it will include frequent breaking changes. This project may be abandoned at any time. If you find it useful, it is strongly encouraged to create a fork and remain on a commit that works for your needs unless you are willing to make the necessary changes to use the latest version. This project is currently NOT accepting contributions and suggestions; please see the dev_guidance.md for more details.
Getting Started
git clone https://github.com/microsoft/recipe-tool.git
cd recipe-tool
Overview
This project is designed to help you automate tasks and generate new recipes using a flexible orchestration system. It consists of two main components: the Recipe Executor and the Recipe Creator.
Recipe Executor
The Recipe Executor is a tool for executing recipes defined in JSON format. It can perform various tasks, including file reading/writing, LLM generation, and sub-recipe execution. The executor uses a context system to manage shared state and data between steps.
Recipe Creator
The Recipe Creator is a tool for generating new recipes based on a recipe idea. It uses the Recipe Executor to create JSON recipe files that can be executed later. The creator can also take additional files as input to provide context for the recipe generation.
Key Components
- Recipe Executor: Executes recipes defined in JSON format.
- Recipe Creator: Generates new recipes based on a recipe idea.
- Recipe Format: JSON-based recipe definitions with steps
- Context Management: Manages shared state and data between steps in a recipe.
- Step Types: Various operations including file reading/writing, LLM generation, and sub-recipe execution
- LLM Integration: Supports various LLMs for generating content and executing tasks.
- File Management: Reads and writes files as part of the recipe execution process.
- Sub-Recipe Execution: Allows for executing other recipes as part of a larger recipe.
- Logging: Provides logging for debugging and tracking recipe execution.
- Template Rendering: Liquid templates for dynamic content generation
Setup and Installation
Prerequisites
Recommended installers:
Azure CLI for Azure OpenAI using Managed Identity
If you plan on using Azure OpenAI with Managed Identity, you need to install the Azure CLI. Follow the instructions for your platform:
- Windows: Install the Azure CLI on Windows
- Linux: Install the Azure CLI on Linux
- macOS: Install the Azure CLI on macOS
Execute the following command to log in:
az login
This command will open a browser window for you to log in. If you are using Managed Identity, ensure that your Azure CLI is configured to use the correct identity.
Development tools
The core dependencies you need to install are:
make- for scripting installation steps of the various projects within this repouv- for managing installed versions ofpython- for installing python dependenciesGitHub cli- forai-context-filesmanipulation tool
Linux:
# make is installed by default on linux
sudo apt update && sudo apt install pipx && sudo apt install gh
pipx ensurepath
pipx install uv
macOS:
brew install make
brew install uv
brew install gh
Windows:
winget install ezwinports.make -e
winget install astral-sh.uv -e
winget install GitHub.cli -e
Setup Steps
- Clone this repository
- Copy the environment file and configure your API keys:
cp .env.example .env # Edit .env to add your OPENAI_API_KEY and other optional API keys
- Run the setup command to create a virtual environment and install dependencies:
make
- Activate the virtual environment:
- Linux/macOS:
source .venv/bin/activate
- Windows:
.\.venv\Scripts\activate
- Linux/macOS:
- Test the installation by running the example recipe:
make recipe-executor-create
Using the Makefile
The project includes several useful make commands:
make: Sets up the virtual environment and installs all dependenciesmake ai-context-files: Builds AI context files for recipe executor developmentmake recipe-executor-create: Generates recipe executor code from scratch using the recipe itselfmake recipe-executor-edit: Revises existing recipe executor code using recipes
Running Recipes via Command Line
Execute a recipe using the command line interface:
recipe-tool --execute path/to/your/recipe.json
You can also pass context variables:
recipe-tool --execute path/to/your/recipe.json context_key=value context_key2=value2
Example:
recipe-tool --execute recipes/example_simple/test_recipe.json model=azure/o4-mini
Creating New Recipes from a Recipe Idea
Create a new recipe using the command line interface:
recipe-tool --create path/to/your/recipe_idea.txt
This will generate a new recipe file based on the provided idea. You can also pass additional files for context:
recipe-tool --create path/to/your/recipe_idea.txt files=path/to/other_file.txt,path/to/another_file.txt
Example:
recipe-tool --create recipes/recipe_creator/prompts/sample_recipe_idea.md
# Test it out
recipe-tool --execute output/analyze_codebase.json input=ai_context/generated/RECIPE_EXECUTOR_CODE_FILES.md,ai_context/generated/RECIPE_EXECUTOR_RECIPE_FILES.md
Project Structure
The project contains:
recipe_tool.py: The main entry point for the command line interface for both recipe execution and creationrecipe_executor/: Core implementation with modules for execution, context management, and stepsrecipes/: Recipe definition files that can be executed
Building from Recipes
One of the more interesting aspects of this project is that it can generate its own code using recipes:
-
To generate the code from scratch:
make recipe-executor-create -
To edit/revise existing code:
make recipe-executor-edit
This demonstrates the power of the Recipe Executor for code generation and maintenance tasks.
Contributing
This project is currently NOT accepting contributions and suggestions; please see the dev_guidance.md for more details.
Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file recipe_tool-0.1.1.tar.gz.
File metadata
- Download URL: recipe_tool-0.1.1.tar.gz
- Upload date:
- Size: 765.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66f0770027025331be5899767fc87c1575128c2dead9c04cb1df928a302b1c60
|
|
| MD5 |
ec28ac300ca592e7e77407c88dfcb4f1
|
|
| BLAKE2b-256 |
7dab6ef1bb4b66683d2d87e115d84a31e73b68f97f7b8d32ea07a1c2dd74acc7
|
File details
Details for the file recipe_tool-0.1.1-py3-none-any.whl.
File metadata
- Download URL: recipe_tool-0.1.1-py3-none-any.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
581194248e5de4813544ef85cd1db41bc515c10d51fdce60800b2a23f8144fe9
|
|
| MD5 |
5f2a0e51241263b00caf2f2d92b5c0cf
|
|
| BLAKE2b-256 |
b0672d7d72bef67d37809a239c8a27fd4396d0d38198976062cd3e1e04d61ad9
|