Skip to main content
Let’s build a graph which can generate unique introductions in multiple languages simultaneously. Key concepts demonstrated:
  • Using context - to pass data between nodes in a graph
  • Using SequentialGraphBuilder to easily build simple graphs
  • Jinja rendering - to create dynamic prompts for LLMs
  • LLM - for generating the agent text response
  • Text-to-speech (TTS) - for generating agent speech audio
  • Parallel execution of graphs
In a Custom Node’s process() method, the first argument is context, which contains a datastore which can be used to read and write data across your graph. In this example, we will use context.getDatastore() to access the datastore in Custom Nodes. The first node in our graph will use datastore.add() to write to the datastore. Later, our TTS node will use datastore.get() to read from it.
Architecture
  • Backend: Inworld Agent Runtime
  • Frontend: N/A (CLI example)

Prerequisites

Getting Started

  1. Clone the templates repository:
  2. In that project folder, run npm install to download the Inworld Agent Runtime and other dependencies
  3. Run npm install wav-encoder so we can create our audio files
  4. Create an .env file and add your Base64 Runtime API key:
.env
  1. Create a new file called process-context.ts and paste in the following code:
process-context.ts
  1. Run npx ts-node process-context.ts to run the Graph
  2. Play the audio files located in the audio_output folder