@inworld/cli 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/index.js +3893 -0
- package/dist/index.js.map +7 -0
- package/dist/src/templates/llm_tts/README.md +161 -0
- package/dist/src/templates/llm_tts/graph.ts +30 -0
- package/dist/src/templates/llm_tts/metadata.json +41 -0
- package/dist/src/templates/simple/README.md +106 -0
- package/dist/src/templates/simple/graph.ts +32 -0
- package/dist/src/templates/simple/metadata.json +26 -0
- package/dist/templates/llm_tts/README.md +155 -0
- package/dist/templates/llm_tts/graph.ts +30 -0
- package/dist/templates/llm_tts/metadata.json +41 -0
- package/dist/templates/simple/README.md +106 -0
- package/dist/templates/simple/graph.ts +32 -0
- package/dist/templates/simple/metadata.json +26 -0
- package/package.json +46 -0
- package/src/templates/llm_tts/README.md +155 -0
- package/src/templates/llm_tts/graph.ts +30 -0
- package/src/templates/llm_tts/metadata.json +41 -0
- package/src/templates/simple/README.md +106 -0
- package/src/templates/simple/graph.ts +32 -0
- package/src/templates/simple/metadata.json +26 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# LLM + TTS Pipeline Graph
|
|
2
|
+
|
|
3
|
+
This is an Inworld Runtime graph that creates a complete conversational AI pipeline with LLM chat and text-to-speech capabilities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This template provides a production-ready pipeline that:
|
|
8
|
+
|
|
9
|
+
- Accepts user input and formats it for LLM processing
|
|
10
|
+
- Sends requests to an LLM provider (OpenAI GPT-4o-mini by default)
|
|
11
|
+
- Streams responses for better user experience
|
|
12
|
+
- Chunks text for optimal TTS processing
|
|
13
|
+
- Converts text responses to speech using TTS
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Configuration
|
|
24
|
+
|
|
25
|
+
Before running, you'll need to set up your API keys:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Set your OpenAI API key (for LLM)
|
|
29
|
+
export OPENAI_API_KEY="your-openai-api-key"
|
|
30
|
+
|
|
31
|
+
# Set your TTS provider credentials (if using a specific provider)
|
|
32
|
+
export TTS_API_KEY="your-tts-api-key"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Running the Graph
|
|
36
|
+
|
|
37
|
+
#### As a server (recommended):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm start
|
|
41
|
+
# or
|
|
42
|
+
npx inworld serve {{graphFileName}}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Direct execution:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run run
|
|
49
|
+
# or
|
|
50
|
+
npx inworld run {{graphFileName}}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Project Structure
|
|
54
|
+
|
|
55
|
+
- **`{{graphFileName}}`** - Main graph file with the LLM-TTS pipeline
|
|
56
|
+
- **`package.json`** - Project dependencies and scripts
|
|
57
|
+
- **`README.md`** - This file
|
|
58
|
+
|
|
59
|
+
## Pipeline Architecture
|
|
60
|
+
|
|
61
|
+
The graph uses a `SequentialGraphBuilder` with the following nodes in order:
|
|
62
|
+
|
|
63
|
+
1. **LLMChatRequestBuilderNode**: Formats user input into LLM chat messages
|
|
64
|
+
2. **RemoteLLMChatNode**: Sends requests to the LLM provider and receives responses
|
|
65
|
+
3. **TextChunkingNode**: Breaks text into optimal chunks for TTS processing
|
|
66
|
+
4. **RemoteTTSNode**: Converts text chunks to speech
|
|
67
|
+
|
|
68
|
+
## Customization
|
|
69
|
+
|
|
70
|
+
### Changing the LLM Provider
|
|
71
|
+
|
|
72
|
+
Edit the `RemoteLLMChatNode` configuration in `{{graphFileName}}`:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
new RemoteLLMChatNode({
|
|
76
|
+
provider: 'anthropic', // Change to 'anthropic', 'google', etc.
|
|
77
|
+
modelName: 'claude-3-sonnet', // Change to desired model
|
|
78
|
+
stream: true,
|
|
79
|
+
// Add other provider-specific options
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Modifying the System Prompt
|
|
84
|
+
|
|
85
|
+
Add system messages to the `LLMChatRequestBuilderNode`:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
new LLMChatRequestBuilderNode({
|
|
89
|
+
messages: [
|
|
90
|
+
{
|
|
91
|
+
role: 'system',
|
|
92
|
+
content: { type: 'text', text: 'You are a helpful assistant...' },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
role: 'user',
|
|
96
|
+
content: { type: 'template', template: '{{user_input}}' },
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Customizing TTS Settings
|
|
103
|
+
|
|
104
|
+
Configure the TTS node for different voices or providers:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
new RemoteTTSNode({
|
|
108
|
+
speakerId: 'Dennis',
|
|
109
|
+
modelId: 'inworld-tts-1-max',
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Adding Additional Processing
|
|
114
|
+
|
|
115
|
+
You can insert additional nodes into the pipeline:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const graphBuilder = new SequentialGraphBuilder({
|
|
119
|
+
id: 'custom-text-node-llm',
|
|
120
|
+
nodes: [
|
|
121
|
+
new LLMChatRequestBuilderNode({...}),
|
|
122
|
+
new RemoteLLMChatNode({...}),
|
|
123
|
+
new CustomProcessingNode(), // Your custom node
|
|
124
|
+
new TextChunkingNode(),
|
|
125
|
+
new RemoteTTSNode(),
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Environment Variables
|
|
131
|
+
|
|
132
|
+
The following environment variables can be configured:
|
|
133
|
+
|
|
134
|
+
- `OPENAI_API_KEY`: API key for OpenAI (required for GPT models)
|
|
135
|
+
- `ANTHROPIC_API_KEY`: API key for Anthropic (if using Claude)
|
|
136
|
+
- `GOOGLE_API_KEY`: API key for Google (if using Gemini)
|
|
137
|
+
- `TTS_API_KEY`: API key for your TTS provider
|
|
138
|
+
|
|
139
|
+
## Deployment
|
|
140
|
+
|
|
141
|
+
To package your graph for deployment:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npx inworld deploy {{graphFileName}}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
This will create a deployment package that can be uploaded to Inworld Cloud.
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
For more information about:
|
|
152
|
+
|
|
153
|
+
- Inworld Runtime: Visit the [documentation](https://docs.inworld.ai/)
|
|
154
|
+
- LLM providers: Check provider-specific documentation
|
|
155
|
+
- TTS options: See the TTS provider documentation
|
|
156
|
+
|
|
157
|
+
## Requirements
|
|
158
|
+
|
|
159
|
+
- Node.js >= 18.0.0
|
|
160
|
+
- @inworld/cli package
|
|
161
|
+
- Valid API keys for LLM and TTS providers
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LLMChatRequestBuilderNode,
|
|
3
|
+
RemoteLLMChatNode,
|
|
4
|
+
RemoteTTSNode,
|
|
5
|
+
SequentialGraphBuilder,
|
|
6
|
+
TextChunkingNode,
|
|
7
|
+
} from '@inworld/runtime/graph';
|
|
8
|
+
|
|
9
|
+
const graphBuilder = new SequentialGraphBuilder({
|
|
10
|
+
id: 'custom-text-node-llm',
|
|
11
|
+
nodes: [
|
|
12
|
+
new LLMChatRequestBuilderNode({
|
|
13
|
+
messages: [
|
|
14
|
+
{
|
|
15
|
+
role: 'user',
|
|
16
|
+
content: { type: 'template', template: '{{user_input}}' },
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
}),
|
|
20
|
+
new RemoteLLMChatNode({
|
|
21
|
+
provider: 'openai',
|
|
22
|
+
modelName: 'gpt-4o-mini',
|
|
23
|
+
stream: true,
|
|
24
|
+
}),
|
|
25
|
+
new TextChunkingNode(),
|
|
26
|
+
new RemoteTTSNode(),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const graph = graphBuilder.build();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "LLM + TTS Pipeline",
|
|
3
|
+
"displayName": "LLM Chat with Text-to-Speech",
|
|
4
|
+
"description": "A production-ready pipeline that processes user input through an LLM (GPT-4o-mini by default) and converts the response to speech using TTS. Includes streaming support for better user experience.",
|
|
5
|
+
"tags": ["llm", "tts", "openai", "voice", "streaming"],
|
|
6
|
+
"defaultProjectName": "llm-tts-graph",
|
|
7
|
+
"examples": {
|
|
8
|
+
"curlCommand": "curl http://localhost:3000/v1/graph:start -X POST -H 'Content-Type: application/json' -d '{\"input\": {\"user_input\":\"What is the weather like today?\"}}'",
|
|
9
|
+
"inputExample": {
|
|
10
|
+
"user_input": "What is the weather like today?"
|
|
11
|
+
},
|
|
12
|
+
"outputExample": {
|
|
13
|
+
"text": "I don't have access to real-time weather data...",
|
|
14
|
+
"audio": "base64_encoded_audio_data..."
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"features": [
|
|
18
|
+
"LLM integration (OpenAI GPT-4o-mini)",
|
|
19
|
+
"Text-to-Speech conversion",
|
|
20
|
+
"Streaming responses",
|
|
21
|
+
"Text chunking for optimal TTS",
|
|
22
|
+
"Configurable providers"
|
|
23
|
+
],
|
|
24
|
+
"requirements": {
|
|
25
|
+
"node": ">=18.0.0",
|
|
26
|
+
"dependencies": ["@inworld/runtime"],
|
|
27
|
+
"apiKeys": ["OPENAI_API_KEY"],
|
|
28
|
+
"optionalApiKeys": ["TTS_API_KEY"]
|
|
29
|
+
},
|
|
30
|
+
"configuration": {
|
|
31
|
+
"llm": {
|
|
32
|
+
"provider": "openai",
|
|
33
|
+
"model": "gpt-4o-mini",
|
|
34
|
+
"streaming": true
|
|
35
|
+
},
|
|
36
|
+
"tts": {
|
|
37
|
+
"provider": "default",
|
|
38
|
+
"voice": "default"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Simple Custom Node Graph
|
|
2
|
+
|
|
3
|
+
This is a simple Inworld Runtime graph project that demonstrates creating a custom node.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This template provides a basic example of:
|
|
8
|
+
|
|
9
|
+
- Creating a custom node by extending `CustomNode`
|
|
10
|
+
- Processing input text and returning transformed output
|
|
11
|
+
- Setting up a single-node graph with start and end points
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Running the Graph
|
|
22
|
+
|
|
23
|
+
#### As a server (recommended):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm start
|
|
27
|
+
# or
|
|
28
|
+
npx inworld serve {{graphFileName}}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### Direct execution:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm run run
|
|
35
|
+
# or
|
|
36
|
+
npx inworld run {{graphFileName}}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Project Structure
|
|
40
|
+
|
|
41
|
+
- **`{{graphFileName}}`** - Main graph file containing your custom node implementation
|
|
42
|
+
- **`package.json`** - Project dependencies and scripts
|
|
43
|
+
- **`README.md`** - This file
|
|
44
|
+
|
|
45
|
+
## How It Works
|
|
46
|
+
|
|
47
|
+
The template includes:
|
|
48
|
+
|
|
49
|
+
1. **CustomTextNode**: A custom node that processes input text (converts to uppercase as an example)
|
|
50
|
+
2. **GraphBuilder**: Creates a graph with the custom node as both start and end point
|
|
51
|
+
3. **Graph Export**: Exports the built graph for use with Inworld CLI or Graph Server
|
|
52
|
+
|
|
53
|
+
## Customization
|
|
54
|
+
|
|
55
|
+
### Modifying the Custom Node
|
|
56
|
+
|
|
57
|
+
Edit the `CustomTextNode` class in `{{graphFileName}}` to change how text is processed:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
export class CustomTextNode extends CustomNode {
|
|
61
|
+
async process(
|
|
62
|
+
_context: ProcessContext,
|
|
63
|
+
input: string,
|
|
64
|
+
): Promise<CustomTextOutput> {
|
|
65
|
+
// Add your custom processing logic here
|
|
66
|
+
return {
|
|
67
|
+
processedText: yourTransformFunction(input),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Adding More Nodes
|
|
74
|
+
|
|
75
|
+
You can create additional custom nodes and chain them together:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const node1 = new FirstCustomNode();
|
|
79
|
+
const node2 = new SecondCustomNode();
|
|
80
|
+
|
|
81
|
+
const graphBuilder = new GraphBuilder('my-graph')
|
|
82
|
+
.addNode(node1)
|
|
83
|
+
.addNode(node2)
|
|
84
|
+
.setStartNode(node1)
|
|
85
|
+
.setEndNode(node2)
|
|
86
|
+
.connectNodes(node1, node2);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Deployment
|
|
90
|
+
|
|
91
|
+
To package your graph for deployment:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx inworld deploy {{graphFileName}}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This will create a deployment package that can be uploaded to Inworld Cloud.
|
|
98
|
+
|
|
99
|
+
## Documentation
|
|
100
|
+
|
|
101
|
+
For more information about Inworld Runtime, visit the [documentation](https://docs.inworld.ai/).
|
|
102
|
+
|
|
103
|
+
## Requirements
|
|
104
|
+
|
|
105
|
+
- Node.js >= 18.0.0
|
|
106
|
+
- @inworld/cli package
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CustomNode,
|
|
3
|
+
GraphBuilder,
|
|
4
|
+
ProcessContext,
|
|
5
|
+
} from '@inworld/runtime/graph';
|
|
6
|
+
|
|
7
|
+
interface CustomTextOutput {
|
|
8
|
+
processedText: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Define a custom node that processes the input text
|
|
12
|
+
export class CustomTextNode extends CustomNode {
|
|
13
|
+
async process(
|
|
14
|
+
_context: ProcessContext,
|
|
15
|
+
input: string,
|
|
16
|
+
): Promise<CustomTextOutput> {
|
|
17
|
+
return {
|
|
18
|
+
processedText: input.toUpperCase(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Create an instance of the custom node
|
|
23
|
+
const customTextNode = new CustomTextNode();
|
|
24
|
+
|
|
25
|
+
// Creating a simple single-node graph builder instance and adding the node to it.
|
|
26
|
+
const graphBuilder = new GraphBuilder('custom-text-node')
|
|
27
|
+
.addNode(customTextNode)
|
|
28
|
+
.setStartNode(customTextNode)
|
|
29
|
+
.setEndNode(customTextNode);
|
|
30
|
+
|
|
31
|
+
// Export graph to be used by Inworld CLI or Inworld Graph Server.
|
|
32
|
+
export const graph = graphBuilder.build();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Simple Custom Node",
|
|
3
|
+
"displayName": "Simple Custom Node Graph",
|
|
4
|
+
"description": "A basic example demonstrating how to create a custom node that processes text input. Perfect for learning the basics of the Inworld Runtime graph system.",
|
|
5
|
+
"tags": ["beginner", "custom-node", "text-processing"],
|
|
6
|
+
"defaultProjectName": "simple-graph",
|
|
7
|
+
"examples": {
|
|
8
|
+
"curlCommand": "curl -X POST http://localhost:8080/process -H 'Content-Type: application/json' -d '{\"text\":\"Hello World\"}'",
|
|
9
|
+
"inputExample": {
|
|
10
|
+
"text": "Hello World"
|
|
11
|
+
},
|
|
12
|
+
"outputExample": {
|
|
13
|
+
"processedText": "HELLO WORLD"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"features": [
|
|
17
|
+
"Custom node implementation",
|
|
18
|
+
"Text processing pipeline",
|
|
19
|
+
"Simple graph structure",
|
|
20
|
+
"TypeScript support"
|
|
21
|
+
],
|
|
22
|
+
"requirements": {
|
|
23
|
+
"node": ">=18.0.0",
|
|
24
|
+
"dependencies": ["@inworld/runtime"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# LLM + TTS Pipeline Graph
|
|
2
|
+
|
|
3
|
+
This is an Inworld Runtime graph that creates a complete conversational AI pipeline with LLM chat and text-to-speech capabilities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This template provides a production-ready pipeline that:
|
|
8
|
+
|
|
9
|
+
- Accepts user input and formats it for LLM processing
|
|
10
|
+
- Sends requests to an LLM provider (OpenAI GPT-4o-mini by default)
|
|
11
|
+
- Streams responses for better user experience
|
|
12
|
+
- Chunks text for optimal TTS processing
|
|
13
|
+
- Converts text responses to speech using TTS
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Configuration
|
|
24
|
+
|
|
25
|
+
Before running, you'll need to set up your API keys:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Set your Inworld API key
|
|
29
|
+
export INWORLD_API_KEY="your-inworld-api-key"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Running the Graph
|
|
33
|
+
|
|
34
|
+
#### As a server (recommended):
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm start
|
|
38
|
+
# or
|
|
39
|
+
npx inworld serve {{graphFileName}}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Direct execution:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run run
|
|
46
|
+
# or
|
|
47
|
+
npx inworld run {{graphFileName}}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Project Structure
|
|
51
|
+
|
|
52
|
+
- **`{{graphFileName}}`** - Main graph file with the LLM-TTS pipeline
|
|
53
|
+
- **`package.json`** - Project dependencies and scripts
|
|
54
|
+
- **`README.md`** - This file
|
|
55
|
+
|
|
56
|
+
## Pipeline Architecture
|
|
57
|
+
|
|
58
|
+
The graph uses a `SequentialGraphBuilder` with the following nodes in order:
|
|
59
|
+
|
|
60
|
+
1. **LLMChatRequestBuilderNode**: Formats user input into LLM chat messages
|
|
61
|
+
2. **RemoteLLMChatNode**: Sends requests to the LLM provider and receives responses
|
|
62
|
+
3. **TextChunkingNode**: Breaks text into optimal chunks for TTS processing
|
|
63
|
+
4. **RemoteTTSNode**: Converts text chunks to speech
|
|
64
|
+
|
|
65
|
+
## Customization
|
|
66
|
+
|
|
67
|
+
### Changing the LLM Provider
|
|
68
|
+
|
|
69
|
+
Edit the `RemoteLLMChatNode` configuration in `{{graphFileName}}`:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
new RemoteLLMChatNode({
|
|
73
|
+
provider: 'anthropic', // Change to 'anthropic', 'google', etc.
|
|
74
|
+
modelName: 'claude-3-sonnet', // Change to desired model
|
|
75
|
+
stream: true,
|
|
76
|
+
// Add other provider-specific options
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Modifying the System Prompt
|
|
81
|
+
|
|
82
|
+
Add system messages to the `LLMChatRequestBuilderNode`:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
new LLMChatRequestBuilderNode({
|
|
86
|
+
messages: [
|
|
87
|
+
{
|
|
88
|
+
role: 'system',
|
|
89
|
+
content: { type: 'text', text: 'You are a helpful assistant...' },
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
role: 'user',
|
|
93
|
+
content: { type: 'template', template: '{{user_input}}' },
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Customizing TTS Settings
|
|
100
|
+
|
|
101
|
+
Configure the TTS node for different voices or providers:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
new RemoteTTSNode({
|
|
105
|
+
speakerId: 'Dennis',
|
|
106
|
+
modelId: 'inworld-tts-1-max',
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Adding Additional Processing
|
|
111
|
+
|
|
112
|
+
You can insert additional nodes into the pipeline:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
const graphBuilder = new SequentialGraphBuilder({
|
|
116
|
+
id: 'custom-text-node-llm',
|
|
117
|
+
nodes: [
|
|
118
|
+
new LLMChatRequestBuilderNode({...}),
|
|
119
|
+
new RemoteLLMChatNode({...}),
|
|
120
|
+
new CustomProcessingNode(), // Your custom node
|
|
121
|
+
new TextChunkingNode(),
|
|
122
|
+
new RemoteTTSNode(),
|
|
123
|
+
],
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Environment Variables
|
|
128
|
+
|
|
129
|
+
The following environment variables can be configured:
|
|
130
|
+
|
|
131
|
+
- `INWORLD_API_KEY`: API key for OpenAI (required for GPT models)
|
|
132
|
+
|
|
133
|
+
## Deployment
|
|
134
|
+
|
|
135
|
+
To package your graph for deployment:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npx inworld deploy {{graphFileName}}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This will create a deployment package that can be uploaded to Inworld Cloud.
|
|
142
|
+
|
|
143
|
+
## Documentation
|
|
144
|
+
|
|
145
|
+
For more information about:
|
|
146
|
+
|
|
147
|
+
- Inworld Runtime: Visit the [documentation](https://docs.inworld.ai/)
|
|
148
|
+
- LLM providers: Check provider-specific documentation
|
|
149
|
+
- TTS options: See the TTS provider documentation
|
|
150
|
+
|
|
151
|
+
## Requirements
|
|
152
|
+
|
|
153
|
+
- Node.js >= 18.0.0
|
|
154
|
+
- @inworld/cli package
|
|
155
|
+
- Valid Inworld API key
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LLMChatRequestBuilderNode,
|
|
3
|
+
RemoteLLMChatNode,
|
|
4
|
+
RemoteTTSNode,
|
|
5
|
+
SequentialGraphBuilder,
|
|
6
|
+
TextChunkingNode,
|
|
7
|
+
} from '@inworld/runtime/graph';
|
|
8
|
+
|
|
9
|
+
const graphBuilder = new SequentialGraphBuilder({
|
|
10
|
+
id: 'custom-text-node-llm',
|
|
11
|
+
nodes: [
|
|
12
|
+
new LLMChatRequestBuilderNode({
|
|
13
|
+
messages: [
|
|
14
|
+
{
|
|
15
|
+
role: 'user',
|
|
16
|
+
content: { type: 'template', template: '{{user_input}}' },
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
}),
|
|
20
|
+
new RemoteLLMChatNode({
|
|
21
|
+
provider: 'openai',
|
|
22
|
+
modelName: 'gpt-4o-mini',
|
|
23
|
+
stream: true,
|
|
24
|
+
}),
|
|
25
|
+
new TextChunkingNode(),
|
|
26
|
+
new RemoteTTSNode(),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const graph = graphBuilder.build();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "LLM + TTS Pipeline",
|
|
3
|
+
"displayName": "LLM Chat with Text-to-Speech",
|
|
4
|
+
"description": "A production-ready pipeline that processes user input through an LLM (GPT-4o-mini by default) and converts the response to speech using TTS. Includes streaming support for better user experience.",
|
|
5
|
+
"tags": ["llm", "tts", "openai", "voice", "streaming"],
|
|
6
|
+
"defaultProjectName": "llm-tts-graph",
|
|
7
|
+
"examples": {
|
|
8
|
+
"curlCommand": "curl http://localhost:3000/v1/graph:start -X POST -H 'Content-Type: application/json' -d '{\"input\": {\"user_input\":\"What is the weather like today?\"}}'",
|
|
9
|
+
"inputExample": {
|
|
10
|
+
"user_input": "What is the weather like today?"
|
|
11
|
+
},
|
|
12
|
+
"outputExample": {
|
|
13
|
+
"text": "I don't have access to real-time weather data...",
|
|
14
|
+
"audio": "base64_encoded_audio_data..."
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"features": [
|
|
18
|
+
"LLM integration (OpenAI GPT-4o-mini)",
|
|
19
|
+
"Text-to-Speech conversion",
|
|
20
|
+
"Streaming responses",
|
|
21
|
+
"Text chunking for optimal TTS",
|
|
22
|
+
"Configurable providers"
|
|
23
|
+
],
|
|
24
|
+
"requirements": {
|
|
25
|
+
"node": ">=18.0.0",
|
|
26
|
+
"dependencies": ["@inworld/runtime"],
|
|
27
|
+
"apiKeys": ["INWORLD_API_KEY"],
|
|
28
|
+
"optionalApiKeys": []
|
|
29
|
+
},
|
|
30
|
+
"configuration": {
|
|
31
|
+
"llm": {
|
|
32
|
+
"provider": "openai",
|
|
33
|
+
"model": "gpt-4o-mini",
|
|
34
|
+
"streaming": true
|
|
35
|
+
},
|
|
36
|
+
"tts": {
|
|
37
|
+
"provider": "default",
|
|
38
|
+
"voice": "default"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|