mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(Google Vertex Chat Model Node): Add support for Google Vertex AI Chat models (#9970)
Co-authored-by: oleg <oleg@n8n.io>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import type { HarmBlockThreshold, HarmCategory } from '@google/generative-ai';
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import { harmCategories, harmThresholds } from './safety-options';
|
||||
|
||||
export const additionalOptions: INodeProperties = {
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
placeholder: 'Add Option',
|
||||
description: 'Additional options to add',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Maximum Number of Tokens',
|
||||
name: 'maxOutputTokens',
|
||||
default: 2048,
|
||||
description: 'The maximum number of tokens to generate in the completion',
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
displayName: 'Sampling Temperature',
|
||||
name: 'temperature',
|
||||
default: 0.4,
|
||||
typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
|
||||
description:
|
||||
'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
displayName: 'Top K',
|
||||
name: 'topK',
|
||||
default: 32,
|
||||
typeOptions: { maxValue: 40, minValue: -1, numberPrecision: 1 },
|
||||
description:
|
||||
'Used to remove "long tail" low probability responses. Defaults to -1, which disables it.',
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
displayName: 'Top P',
|
||||
name: 'topP',
|
||||
default: 1,
|
||||
typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
|
||||
description:
|
||||
'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',
|
||||
type: 'number',
|
||||
},
|
||||
|
||||
// Safety Settings
|
||||
{
|
||||
displayName: 'Safety Settings',
|
||||
name: 'safetySettings',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: { multipleValues: true },
|
||||
default: {
|
||||
values: {
|
||||
category: harmCategories[0].name as HarmCategory,
|
||||
threshold: harmThresholds[0].name as HarmBlockThreshold,
|
||||
},
|
||||
},
|
||||
placeholder: 'Add Option',
|
||||
options: [
|
||||
{
|
||||
name: 'values',
|
||||
displayName: 'Values',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Safety Category',
|
||||
name: 'category',
|
||||
type: 'options',
|
||||
description: 'The category of harmful content to block',
|
||||
default: 'HARM_CATEGORY_UNSPECIFIED',
|
||||
options: harmCategories,
|
||||
},
|
||||
{
|
||||
displayName: 'Safety Threshold',
|
||||
name: 'threshold',
|
||||
type: 'options',
|
||||
description: 'The threshold of harmful content to block',
|
||||
default: 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
|
||||
options: harmThresholds,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { INodePropertyOptions } from 'n8n-workflow';
|
||||
|
||||
export const harmCategories: INodePropertyOptions[] = [
|
||||
{
|
||||
value: 'HARM_CATEGORY_HARASSMENT',
|
||||
name: 'HARM_CATEGORY_HARASSMENT',
|
||||
description: 'Harassment content',
|
||||
},
|
||||
{
|
||||
value: 'HARM_CATEGORY_HATE_SPEECH',
|
||||
name: 'HARM_CATEGORY_HATE_SPEECH',
|
||||
description: 'Hate speech and content',
|
||||
},
|
||||
{
|
||||
value: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
||||
name: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
||||
description: 'Sexually explicit content',
|
||||
},
|
||||
{
|
||||
value: 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
||||
name: 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
||||
description: 'Dangerous content',
|
||||
},
|
||||
];
|
||||
|
||||
export const harmThresholds: INodePropertyOptions[] = [
|
||||
{
|
||||
value: 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
|
||||
name: 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
|
||||
description: 'Threshold is unspecified',
|
||||
},
|
||||
{
|
||||
value: 'BLOCK_LOW_AND_ABOVE',
|
||||
name: 'BLOCK_LOW_AND_ABOVE',
|
||||
description: 'Content with NEGLIGIBLE will be allowed',
|
||||
},
|
||||
{
|
||||
value: 'BLOCK_MEDIUM_AND_ABOVE',
|
||||
name: 'BLOCK_MEDIUM_AND_ABOVE',
|
||||
description: 'Content with NEGLIGIBLE and LOW will be allowed',
|
||||
},
|
||||
{
|
||||
value: 'BLOCK_ONLY_HIGH',
|
||||
name: 'BLOCK_ONLY_HIGH',
|
||||
description: 'Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed',
|
||||
},
|
||||
{
|
||||
value: 'BLOCK_NONE',
|
||||
name: 'BLOCK_NONE',
|
||||
description: 'All content will be allowed',
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user