feat: Add fallback mechanism for agent and basic chain llm (#16617)

This commit is contained in:
Benjamin Schroth
2025-06-26 16:14:03 +02:00
committed by GitHub
parent 0b7bca29f8
commit 6408d5a1b0
20 changed files with 476 additions and 140 deletions

View File

@@ -7,26 +7,44 @@ describe('config', () => {
it('should return basic inputs for all parameters', () => {
const inputs = getInputs({});
expect(inputs).toHaveLength(3);
expect(inputs).toHaveLength(4);
expect(inputs[0].type).toBe(NodeConnectionTypes.Main);
expect(inputs[1].type).toBe(NodeConnectionTypes.AiLanguageModel);
expect(inputs[2].type).toBe(NodeConnectionTypes.AiOutputParser);
expect(inputs[2].type).toBe(NodeConnectionTypes.AiLanguageModel);
expect(inputs[3].type).toBe(NodeConnectionTypes.AiOutputParser);
});
it('should exclude the OutputParser when hasOutputParser is false', () => {
const inputs = getInputs({ hasOutputParser: false });
expect(inputs).toHaveLength(2);
expect(inputs).toHaveLength(3);
expect(inputs[0].type).toBe(NodeConnectionTypes.Main);
expect(inputs[1].type).toBe(NodeConnectionTypes.AiLanguageModel);
expect(inputs[2].type).toBe(NodeConnectionTypes.AiLanguageModel);
});
it('should include the OutputParser when hasOutputParser is true', () => {
const inputs = getInputs({ hasOutputParser: true });
expect(inputs).toHaveLength(4);
expect(inputs[3].type).toBe(NodeConnectionTypes.AiOutputParser);
});
it('should exclude the FallbackInput when needsFallback is false', () => {
const inputs = getInputs({ hasOutputParser: true, needsFallback: false });
expect(inputs).toHaveLength(3);
expect(inputs[0].type).toBe(NodeConnectionTypes.Main);
expect(inputs[1].type).toBe(NodeConnectionTypes.AiLanguageModel);
expect(inputs[2].type).toBe(NodeConnectionTypes.AiOutputParser);
});
it('should include the FallbackInput when needsFallback is true', () => {
const inputs = getInputs({ hasOutputParser: false, needsFallback: true });
expect(inputs).toHaveLength(3);
expect(inputs[2].type).toBe(NodeConnectionTypes.AiLanguageModel);
});
});
describe('nodeProperties', () => {