You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can think of routing as an AI traffic controller. Instead of forcing one LLM to handle everything, you first figure out what type of task you're dealing with, then send it to the right specialist.
36
36
37
-
#### Example: Routing
37
+
#### Routing task
38
38
39
39
1. User asks a question.
40
40
2. Determine if the question is simple or complex.
Sometimes you need to do multiple things at once – that's where parallelization comes in. Rather than working through tasks one by one, you split them up and run them simultaneously. This is where batch.triggerByTaskAndWait shines, allowing you to execute multiple tasks in parallel and efficiently coordinate their responses.
49
49
50
-
#### Example: Parallelization
50
+
#### Parallelization task
51
51
52
52
This example responds to customer questions by simultaneously generating a response and checking for inappropriate content.
53
53
@@ -57,13 +57,13 @@ This example responds to customer questions by simultaneously generating a respo
57
57
2. The second task checks for innapropriate content.
58
58
3. The third, main task coordinates the responses by using batch.`triggerByTaskAndWait` to run the two tasks in parallel. If the content is inappropriate, this task returns a message saying it can't process the request, otherwise it returns the generated response.
59
59
60
-
View the Trigger.dev parallelization task code: [src/trigger/trigger/parallelize-tasks.ts](./src/trigger/trigger/parallelize-tasks.ts).
60
+
View the Trigger.dev parallelization task code: [src/trigger/trigger/parallel-llm-calls.ts](./src/trigger/trigger/parallel-llm-calls.ts).
61
61
62
62
### Orchestrator-workers
63
63
64
64
This pattern is like having a project manager (the orchestrator) who breaks down a big job into smaller tasks and assigns them to specialists (the workers). The orchestrator keeps track of everything and puts all the pieces back together at the end. Using batch.triggerByTaskAndWait, it efficiently coordinates multiple tasks while maintaining clear control over the entire workflow.
65
65
66
-
#### Example: Orchestrator-workers
66
+
#### Orchestrator-workers task
67
67
68
68
1. Extracts distinct factual claims from a news article.
69
69
2. Verifies each claim by considering recent news sources and official statements.
Here's where you add quality control to your AI system. The evaluator checks the output, and if it's not quite right, the optimizer suggests improvements. Think of it as having a friendly editor who reviews your work and helps make it better.
0 commit comments