Performance: Prompt composition and chaining
MEDIUM IMPACT
This concept affects the speed and responsiveness of generating outputs by managing how prompts are combined and processed in sequence.
const composedChain = new SequentialChain({chains: [chain1, chain2, chain3], inputVariables: ['userInput']});
const finalResponse = await composedChain.invoke({userInput});const response1 = await chain1.invoke({input: userInput}); const response2 = await chain2.invoke({input: response1}); const response3 = await chain3.invoke({input: response2});
| Pattern | Network Calls | Latency Impact | User Interaction Delay | Verdict |
|---|---|---|---|---|
| Multiple sequential calls | 3 calls for 3 prompts | High latency due to waiting on each call | Longer delay before UI update | [X] Bad |
| Composed prompt chain | 1 combined call | Lower latency by reducing calls | Faster UI update and response | [OK] Good |