mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(Basic LLM Chain Node): Use JSON parsing for Claude 3.7 with thinking enabled (#15381)
This commit is contained in:
@@ -38,6 +38,18 @@ export function isModelWithResponseFormat(
|
||||
);
|
||||
}
|
||||
|
||||
export function isModelInThinkingMode(
|
||||
llm: BaseLanguageModel,
|
||||
): llm is BaseLanguageModel & { lc_kwargs: { invocationKwargs: { thinking: { type: string } } } } {
|
||||
return (
|
||||
'lc_kwargs' in llm &&
|
||||
'invocationKwargs' in llm.lc_kwargs &&
|
||||
typeof llm.lc_kwargs.invocationKwargs === 'object' &&
|
||||
'thinking' in llm.lc_kwargs.invocationKwargs &&
|
||||
llm.lc_kwargs.invocationKwargs.thinking.type === 'enabled'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if the LLM has a format property(Ollama)
|
||||
*/
|
||||
@@ -61,6 +73,10 @@ export function getOutputParserForLLM(
|
||||
return new NaiveJsonOutputParser();
|
||||
}
|
||||
|
||||
if (isModelInThinkingMode(llm)) {
|
||||
return new NaiveJsonOutputParser();
|
||||
}
|
||||
|
||||
return new StringOutputParser();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user