AI rule node: ensure AI settings exist on rule node init
This commit is contained in:
parent
2e5aab3fd6
commit
ac61136ecc
@ -95,6 +95,10 @@ public final class TbAiNode extends TbAbstractExternalNode implements TbNode {
|
||||
);
|
||||
|
||||
timeoutSeconds = config.getTimeoutSeconds();
|
||||
|
||||
if (!aiSettingsExist(ctx, config.getAiSettingsId())) {
|
||||
throw new TbNodeException("[" + ctx.getTenantId() + "] AI settings with ID: " + config.getAiSettingsId() + " were not found", true);
|
||||
}
|
||||
aiSettingsId = config.getAiSettingsId();
|
||||
}
|
||||
|
||||
@ -105,6 +109,10 @@ public final class TbAiNode extends TbAbstractExternalNode implements TbNode {
|
||||
return responseFormatType == ResponseFormatType.JSON && jsonSchema != null ? Langchain4jJsonSchemaAdapter.fromJsonNode(jsonSchema) : null;
|
||||
}
|
||||
|
||||
private static boolean aiSettingsExist(TbContext ctx, AiSettingsId aiSettingsId) {
|
||||
return ctx.getAiSettingsService().findAiSettingsByTenantIdAndId(ctx.getTenantId(), aiSettingsId).isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsg(TbContext ctx, TbMsg msg) throws TbNodeException {
|
||||
var ackedMsg = ackIfNeeded(ctx, msg);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user