This is an example project demonstrating how to use Hatchet with Typescript.
Before running this project, make sure you have the following:
- Create a
.env
file in the./simple-examples
directory and set the required environment variables. This requires theHATCHET_CLIENT_TOKEN
variable created in the Getting Started README. If you would like to try the Generative AI examples in ./src/genai You will also need, aOPENAI_API_KEY
which can be created on the OpenAI Website.
HATCHET_CLIENT_TLS_STRATEGY=none
HATCHET_CLIENT_TOKEN="<token>"
OPENAI_API_KEY="<openai-key>" # (OPTIONAL) only required to run examples in [./src/genai](./src/genai)
-
Open a terminal and navigate to the project root directory (
/simple-examples
):cd simple-examples
-
Run the following command to install the project dependencies:
npm i
First, start a Hatchet worker by running the following command:
npm run worker:simple
To send an example event, open a new terminal and run the following command:
npm run example:event
Check all example workflows below.
Follow the instructions in the root project setup to launch the playground and start workflow runs.
The project contains example workflows in the ./src
directory. See ./package.json
for available scripts to run workers.
The project includes a variety of basic workflows to demonstrate Hatchet's core capabilities, each showcasing different features:
- Simple Workflow: Demonstrates a straightforward process flow, showcasing the basics of setting up a workflow in Hatchet.
npm run worker:simple
- Concurrency Limit Workflow: Shows how to manage concurrency limits within workflows to ensure that only a certain number of instances run simultaneously.
npm run worker:concurrency
- Directed Acyclic Graph (DAG) Workflow: Illustrates setting up workflows with dependencies that form a Directed Acyclic Graph, demonstrating the advanced orchestration capabilities of Hatchet.
npm run worker:dag
- Manual Trigger Workflow: Explains how to initiate workflows manually, offering control over workflow execution triggers.
npm run worker:manual-trigger
- Retries Workflow: Demonstrates handling retries scenarios within workflows, ensuring that failed or stalled processes are appropriately managed.
npm run worker:retries
To send an example event, open a new terminal and run the following command:
npm run example:event
For more complex use cases, the project includes examples that integrate with OpenAI's API for generative tasks:
- Simple Response Generation: A single-step workflow that makes a request to OpenAI, showcasing how to incorporate AI services into Hatchet workflows.
- Basic Retrieval Augmented Generation (BasicRag): A multi-step workflow that involves loading website content, reasoning about the information, and generating a response with OpenAI, demonstrating the potential for complex, AI-driven processes.