mirror of
				https://github.com/n8n-io/n8n-nodes-starter.git
				synced 2025-10-31 07:12:25 -05:00 
			
		
		
		
	Add DO Gradient Serverless Inference Node
This commit is contained in:
		
					parent
					
						
							
								67ee5b8e80
							
						
					
				
			
			
				commit
				
					
						c3c675ff33
					
				
			
		
					 19 changed files with 5765 additions and 628 deletions
				
			
		|  | @ -0,0 +1,11 @@ | |||
| <svg width="196" height="196" viewBox="0 0 196 196" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||
| <path d="M47.3408 148.115C47.3574 148.023 47.4746 148.494 47.6016 149.161C49.6404 159.873 51.6407 164.16 55.9443 167.039C58.8113 168.957 63.0267 170.284 70.8467 171.731C71.2048 171.798 71.1538 171.814 69.7998 172.078C62.5012 173.499 58.7081 174.733 55.9414 176.587C54.3106 177.68 53.2536 178.736 52.1602 180.366C50.3281 183.097 49.1049 186.808 47.7324 193.798C47.3949 195.517 47.3662 195.613 47.3008 195.262C45.8416 187.417 44.5212 183.229 42.6055 180.369C39.8212 176.212 35.7984 174.254 26.0156 172.293C24.7436 172.038 23.6792 171.809 23.6523 171.803C23.6685 171.799 24.1963 171.677 24.8643 171.553C26.4116 171.266 29.1262 170.673 30.6436 170.291C34.1906 169.398 36.8655 168.325 38.9072 166.975C40.1426 166.158 41.7017 164.606 42.5146 163.385C44.5461 160.332 45.927 155.965 47.3408 148.115ZM0 97.627C0.000131746 33.8237 61.8226 -16.0588 128.758 4.82227C158.042 13.8708 181.283 37.3038 190.58 66.5371C211.497 133.589 161.76 195.305 97.8467 195.305V157.486C138.054 157.486 168.965 117.812 153.626 75.5859C148.048 60.0411 135.497 47.5126 119.926 41.9443C77.6265 26.6316 37.8839 57.721 37.8838 97.627H0ZM77.5518 101.673C77.5736 101.551 77.729 102.173 77.8965 103.053C80.5859 117.183 83.2245 122.838 88.9014 126.636C92.6833 129.166 98.2438 130.917 108.56 132.826C109.032 132.914 108.965 132.935 107.179 133.283C97.5509 135.158 92.547 136.786 88.8975 139.231C86.7464 140.673 85.3525 142.067 83.9102 144.217C81.4935 147.819 79.8798 152.714 78.0693 161.935C77.6242 164.202 77.5862 164.33 77.5 163.866C75.5751 153.518 73.8338 147.993 71.3066 144.22C67.6338 138.736 62.3266 136.153 49.4219 133.566C47.7252 133.226 46.3238 132.936 46.3037 132.92C46.2885 132.905 47.0083 132.756 47.9033 132.59C49.9446 132.211 53.5258 131.43 55.5273 130.927C60.2063 129.749 63.7344 128.333 66.4277 126.552C68.0575 125.474 70.1141 123.427 71.1865 121.815C73.8663 117.788 75.6867 112.027 77.5518 101.673ZM21.5625 121.78C21.5745 121.713 21.6597 122.055 21.752 122.54C23.2335 130.324 24.6872 133.439 27.8145 135.531C29.8977 136.925 32.9605 137.889 38.6426 138.94C38.9031 138.989 38.866 139.001 37.8818 139.192C32.5785 140.225 29.8229 141.123 27.8125 142.47C26.6276 143.264 25.8589 144.031 25.0645 145.215C23.7332 147.199 22.844 149.896 21.8467 154.976C21.6015 156.225 21.5807 156.295 21.5332 156.039C20.4729 150.339 19.514 147.296 18.1221 145.218C16.0989 142.197 13.1751 140.773 6.06641 139.349C5.13025 139.161 4.35709 139.001 4.34863 138.992C4.34871 138.982 4.74259 138.901 5.23047 138.811C6.35498 138.602 8.32724 138.172 9.42969 137.895C12.0071 137.246 13.9509 136.466 15.4346 135.484C16.3322 134.891 17.465 133.764 18.0557 132.876C19.5318 130.658 20.5351 127.484 21.5625 121.78Z" fill="#000C79"/> | ||||
| <path d="M47.3408 148.115C47.3574 148.023 47.4746 148.494 47.6016 149.161C49.6404 159.873 51.6407 164.16 55.9443 167.039C58.8113 168.957 63.0267 170.284 70.8467 171.731C71.2048 171.798 71.1538 171.814 69.7998 172.078C62.5012 173.499 58.7081 174.733 55.9414 176.587C54.3106 177.68 53.2536 178.736 52.1602 180.366C50.3281 183.097 49.1049 186.808 47.7324 193.798C47.3949 195.517 47.3662 195.613 47.3008 195.262C45.8416 187.417 44.5212 183.229 42.6055 180.369C39.8212 176.212 35.7984 174.254 26.0156 172.293C24.7436 172.038 23.6792 171.809 23.6523 171.803C23.6685 171.799 24.1963 171.677 24.8643 171.553C26.4116 171.266 29.1262 170.673 30.6436 170.291C34.1906 169.398 36.8655 168.325 38.9072 166.975C40.1426 166.158 41.7017 164.606 42.5146 163.385C44.5461 160.332 45.927 155.965 47.3408 148.115ZM0 97.627C0.000131746 33.8237 61.8226 -16.0588 128.758 4.82227C158.042 13.8708 181.283 37.3038 190.58 66.5371C211.497 133.589 161.76 195.305 97.8467 195.305V157.486C138.054 157.486 168.965 117.812 153.626 75.5859C148.048 60.0411 135.497 47.5126 119.926 41.9443C77.6265 26.6316 37.8839 57.721 37.8838 97.627H0ZM77.5518 101.673C77.5736 101.551 77.729 102.173 77.8965 103.053C80.5859 117.183 83.2245 122.838 88.9014 126.636C92.6833 129.166 98.2438 130.917 108.56 132.826C109.032 132.914 108.965 132.935 107.179 133.283C97.5509 135.158 92.547 136.786 88.8975 139.231C86.7464 140.673 85.3525 142.067 83.9102 144.217C81.4935 147.819 79.8798 152.714 78.0693 161.935C77.6242 164.202 77.5862 164.33 77.5 163.866C75.5751 153.518 73.8338 147.993 71.3066 144.22C67.6338 138.736 62.3266 136.153 49.4219 133.566C47.7252 133.226 46.3238 132.936 46.3037 132.92C46.2885 132.905 47.0083 132.756 47.9033 132.59C49.9446 132.211 53.5258 131.43 55.5273 130.927C60.2063 129.749 63.7344 128.333 66.4277 126.552C68.0575 125.474 70.1141 123.427 71.1865 121.815C73.8663 117.788 75.6867 112.027 77.5518 101.673ZM21.5625 121.78C21.5745 121.713 21.6597 122.055 21.752 122.54C23.2335 130.324 24.6872 133.439 27.8145 135.531C29.8977 136.925 32.9605 137.889 38.6426 138.94C38.9031 138.989 38.866 139.001 37.8818 139.192C32.5785 140.225 29.8229 141.123 27.8125 142.47C26.6276 143.264 25.8589 144.031 25.0645 145.215C23.7332 147.199 22.844 149.896 21.8467 154.976C21.6015 156.225 21.5807 156.295 21.5332 156.039C20.4729 150.339 19.514 147.296 18.1221 145.218C16.0989 142.197 13.1751 140.773 6.06641 139.349C5.13025 139.161 4.35709 139.001 4.34863 138.992C4.34871 138.982 4.74259 138.901 5.23047 138.811C6.35498 138.602 8.32724 138.172 9.42969 137.895C12.0071 137.246 13.9509 136.466 15.4346 135.484C16.3322 134.891 17.465 133.764 18.0557 132.876C19.5318 130.658 20.5351 127.484 21.5625 121.78Z" fill="url(#paint0_radial_7847_19772)"/> | ||||
| <defs> | ||||
| <radialGradient id="paint0_radial_7847_19772" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(-64.5042 109.279) scale(402.467 106.592)"> | ||||
| <stop stop-color="#FF9FEA"/> | ||||
| <stop offset="0.601298" stop-color="#0069FF"/> | ||||
| <stop offset="1" stop-color="#000C79" stop-opacity="0"/> | ||||
| </radialGradient> | ||||
| </defs> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 5.7 KiB | 
|  | @ -0,0 +1,3 @@ | |||
| <svg width="196" height="196" viewBox="0 0 196 196" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||
| <path d="M47.3408 148.115C47.3574 148.023 47.4746 148.494 47.6016 149.161C49.6404 159.873 51.6407 164.16 55.9443 167.039C58.8113 168.957 63.0267 170.284 70.8467 171.731C71.2048 171.798 71.1538 171.814 69.7998 172.078C62.5012 173.499 58.7081 174.733 55.9414 176.587C54.3106 177.68 53.2536 178.736 52.1602 180.366C50.3281 183.097 49.1049 186.808 47.7324 193.798C47.3949 195.517 47.3662 195.613 47.3008 195.262C45.8416 187.417 44.5212 183.229 42.6055 180.369C39.8212 176.212 35.7984 174.254 26.0156 172.293C24.7436 172.038 23.6792 171.809 23.6523 171.803C23.6685 171.799 24.1963 171.677 24.8643 171.553C26.4116 171.266 29.1262 170.673 30.6436 170.291C34.1906 169.398 36.8655 168.325 38.9072 166.975C40.1426 166.158 41.7017 164.606 42.5146 163.385C44.5461 160.332 45.927 155.965 47.3408 148.115ZM0 97.627C0.000131746 33.8237 61.8226 -16.0588 128.758 4.82227C158.042 13.8708 181.283 37.3038 190.58 66.5371C211.497 133.589 161.76 195.305 97.8467 195.305V157.486C138.054 157.486 168.965 117.812 153.626 75.5859C148.048 60.0411 135.497 47.5126 119.926 41.9443C77.6265 26.6316 37.8839 57.721 37.8838 97.627H0ZM77.5518 101.673C77.5736 101.551 77.729 102.173 77.8965 103.053C80.5859 117.183 83.2245 122.838 88.9014 126.636C92.6833 129.166 98.2438 130.917 108.56 132.826C109.032 132.914 108.965 132.935 107.179 133.283C97.5509 135.158 92.547 136.786 88.8975 139.231C86.7464 140.673 85.3525 142.067 83.9102 144.217C81.4935 147.819 79.8798 152.714 78.0693 161.935C77.6242 164.202 77.5862 164.33 77.5 163.866C75.5751 153.518 73.8338 147.993 71.3066 144.22C67.6339 138.736 62.3266 136.153 49.4219 133.566C47.7252 133.226 46.3238 132.936 46.3037 132.92C46.2885 132.905 47.0083 132.756 47.9033 132.59C49.9446 132.211 53.5258 131.43 55.5273 130.927C60.2063 129.749 63.7344 128.333 66.4277 126.552C68.0575 125.474 70.1141 123.427 71.1865 121.815C73.8663 117.788 75.6867 112.027 77.5518 101.673ZM21.5625 121.78C21.5745 121.713 21.6597 122.055 21.752 122.54C23.2335 130.324 24.6872 133.439 27.8145 135.531C29.8977 136.925 32.9605 137.889 38.6426 138.94C38.9031 138.989 38.866 139.001 37.8818 139.192C32.5785 140.225 29.8229 141.123 27.8125 142.47C26.6276 143.264 25.8589 144.031 25.0645 145.215C23.7332 147.199 22.844 149.896 21.8467 154.976C21.6015 156.225 21.5807 156.295 21.5332 156.039C20.4729 150.339 19.514 147.296 18.1221 145.218C16.0989 142.197 13.1751 140.773 6.06641 139.349C5.13025 139.161 4.35709 139.001 4.34863 138.992C4.34871 138.982 4.74259 138.901 5.23047 138.811C6.35498 138.602 8.32724 138.172 9.42969 137.895C12.0071 137.246 13.9509 136.466 15.4346 135.484C16.3322 134.891 17.465 133.764 18.0557 132.876C19.5318 130.658 20.5351 127.484 21.5625 121.78Z" fill="white"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 2.7 KiB | 
							
								
								
									
										18
									
								
								nodes/ServerlessInferenceNode/GenericFunctions.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								nodes/ServerlessInferenceNode/GenericFunctions.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| import type { | ||||
| 	IExecuteSingleFunctions, | ||||
| 	IN8nHttpFullResponse, | ||||
| 	INodeExecutionData, | ||||
| 	JsonObject, | ||||
| } from 'n8n-workflow'; | ||||
| import { NodeApiError } from 'n8n-workflow'; | ||||
| 
 | ||||
| export async function sendErrorPostReceive( | ||||
| 	this: IExecuteSingleFunctions, | ||||
| 	data: INodeExecutionData[], | ||||
| 	response: IN8nHttpFullResponse, | ||||
| ): Promise<INodeExecutionData[]> { | ||||
| 	if (String(response.statusCode).startsWith('4') || String(response.statusCode).startsWith('5')) { | ||||
| 		throw new NodeApiError(this.getNode(), response as unknown as JsonObject); | ||||
| 	} | ||||
| 	return data; | ||||
| } | ||||
							
								
								
									
										19
									
								
								nodes/ServerlessInferenceNode/ServerlessInference.node.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								nodes/ServerlessInferenceNode/ServerlessInference.node.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| { | ||||
| 	"node": "n8n-nodes-base.ServerlessInference", | ||||
| 	"nodeVersion": "1.0", | ||||
| 	"codexVersion": "1.0", | ||||
| 	"categories": ["Utility"], | ||||
| 	"resources": { | ||||
| 		"credentialDocumentation": [ | ||||
| 			{ | ||||
| 				"url": "https://docs.digitalocean.com/products/gradient-ai-platform/how-to/use-serverless-inference/#create" | ||||
| 			} | ||||
| 		], | ||||
| 		"primaryDocumentation": [ | ||||
| 			{ | ||||
| 				"url": "https://docs.digitalocean.com/products/gradient-ai-platform/how-to/use-serverless-inference/" | ||||
| 			} | ||||
| 		] | ||||
| 	}, | ||||
| 	"alias": ["DoServerlessInference"] | ||||
| } | ||||
							
								
								
									
										55
									
								
								nodes/ServerlessInferenceNode/ServerlessInference.node.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								nodes/ServerlessInferenceNode/ServerlessInference.node.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,55 @@ | |||
| import { INodeType, INodeTypeDescription, NodeConnectionType } from 'n8n-workflow'; | ||||
| 
 | ||||
| import { textFields, textOperations } from './TextDescription'; | ||||
| 
 | ||||
| const baseURL = 'https://inference.do-ai.run/v1'; | ||||
| 
 | ||||
| export class ServerlessInference implements INodeType { | ||||
| 	description: INodeTypeDescription = { | ||||
| 		displayName: 'DigitalOcean Gradient™ AI Serverless Inference', | ||||
| 		documentationUrl: 'https://gradientai-sdk.digitalocean.com/api/resources/chat/subresources/completions/methods/create', | ||||
| 		name: 'digitalOceanGradientServerlessInference', | ||||
| 		icon: { light: 'file:DO-Gradient-AI-Agentic-Cloud-logo.svg', dark: 'file:DO-gradient-ai-logo-white.svg' }, | ||||
| 		group: ['transform'], | ||||
| 		version: [1, 1.0], | ||||
| 		subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', | ||||
| 		description: 'Consume DigitalOcean Gradient™ AI Serverless Inference', | ||||
| 		defaults: { | ||||
| 			name: 'DigitalOcean Gradient™ AI Serverless Inference', | ||||
| 		}, | ||||
| 		inputs: [NodeConnectionType.Main], | ||||
| 		outputs: [NodeConnectionType.Main], | ||||
| 		credentials: [ | ||||
| 			{ | ||||
| 				name: 'digitalOceanServerlessInference', | ||||
| 				required: true, | ||||
| 			}, | ||||
| 		], | ||||
| 		requestDefaults: { | ||||
| 			ignoreHttpStatusErrors: true, | ||||
| 			baseURL, | ||||
|             headers: { | ||||
| 				Accept: 'application/json', | ||||
| 				'Content-Type': 'application/json', | ||||
| 				'User-Agent': 'Gradient/n8n/1.0.0', | ||||
| 			}, | ||||
| 		}, | ||||
| 		properties: [ | ||||
| 			{ | ||||
| 				displayName: 'Resource', | ||||
| 				name: 'resource', | ||||
| 				type: 'options', | ||||
| 				noDataExpression: true, | ||||
| 				options: [ | ||||
| 					{ | ||||
| 						name: 'Text', | ||||
| 						value: 'text', | ||||
| 					}, | ||||
| 				], | ||||
| 				default: 'text', | ||||
| 			}, | ||||
| 			...textOperations, | ||||
| 			...textFields, | ||||
| 		], | ||||
| 	}; | ||||
| } | ||||
							
								
								
									
										623
									
								
								nodes/ServerlessInferenceNode/TextDescription.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										623
									
								
								nodes/ServerlessInferenceNode/TextDescription.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,623 @@ | |||
| import type { INodeProperties } from 'n8n-workflow'; | ||||
| 
 | ||||
| import { sendErrorPostReceive } from './GenericFunctions'; | ||||
| 
 | ||||
| export const textOperations: INodeProperties[] = [ | ||||
| 	{ | ||||
| 		displayName: 'Operation', | ||||
| 		name: 'operation', | ||||
| 		type: 'options', | ||||
| 		noDataExpression: true, | ||||
| 		displayOptions: { | ||||
| 			show: { | ||||
| 				resource: ['text'], | ||||
| 			}, | ||||
| 		}, | ||||
| 		options: [ | ||||
| 			{ | ||||
| 				name: 'Complete', | ||||
| 				value: 'complete', | ||||
| 				action: 'Create a Text Completion', | ||||
| 				description: 'Create one or more completions for a given text', | ||||
| 				routing: { | ||||
| 					request: { | ||||
| 						method: 'POST', | ||||
| 						url: '/chat/completions', | ||||
| 					}, | ||||
| 					output: { postReceive: [sendErrorPostReceive] }, | ||||
| 				}, | ||||
| 			}, | ||||
| 		], | ||||
| 		default: 'complete', | ||||
| 	}, | ||||
| ]; | ||||
| 
 | ||||
| const completeOperations: INodeProperties[] = [ | ||||
| 	{ | ||||
| 		displayName: 'Model', | ||||
| 		name: 'model', | ||||
| 		type: 'options', | ||||
| 		description: | ||||
| 			'The model which will generate the completion. <a href="https://docs.digitalocean.com/products/gradient-ai-platform/details/models/">Learn more</a>', | ||||
| 		displayOptions: { | ||||
| 			show: { | ||||
| 				operation: ['complete'], | ||||
| 				resource: ['text'], | ||||
| 			}, | ||||
| 		}, | ||||
| 		typeOptions: { | ||||
| 			loadOptions: { | ||||
| 				routing: { | ||||
| 					request: { | ||||
| 						method: 'GET', | ||||
| 						url: '/models', | ||||
| 					}, | ||||
| 					output: { | ||||
| 						postReceive: [ | ||||
| 							{ | ||||
| 								type: 'rootProperty', | ||||
| 								properties: { | ||||
| 									property: 'data', | ||||
| 								}, | ||||
| 							}, | ||||
| 							{ | ||||
| 								type: 'setKeyValue', | ||||
| 								properties: { | ||||
| 									name: '={{$responseItem.id}}', | ||||
| 									value: '={{$responseItem.id}}', | ||||
| 								}, | ||||
| 							}, | ||||
| 							{ | ||||
| 								type: 'sort', | ||||
| 								properties: { | ||||
| 									key: 'name', | ||||
| 								}, | ||||
| 							}, | ||||
| 						], | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		routing: { | ||||
| 			send: { | ||||
| 				type: 'body', | ||||
| 				property: 'model', | ||||
| 			}, | ||||
| 		}, | ||||
| 		default: 'openai-gpt-oss-120b', | ||||
| 	}, | ||||
| 	{ | ||||
| 		displayName: 'Input Type', | ||||
| 		name: 'inputType', | ||||
| 		type: 'options', | ||||
| 		description: 'Choose how to provide the conversation input', | ||||
| 		displayOptions: { | ||||
| 			show: { | ||||
| 				resource: ['text'], | ||||
| 				operation: ['complete'], | ||||
| 			}, | ||||
| 		}, | ||||
| 		options: [ | ||||
| 			{ | ||||
| 				name: 'Simple Prompt', | ||||
| 				value: 'prompt', | ||||
| 				description: 'Provide a simple text prompt', | ||||
| 			}, | ||||
| 			{ | ||||
| 				name: 'Chat Messages', | ||||
| 				value: 'messages', | ||||
| 				description: 'Provide a full conversation with roles', | ||||
| 			}, | ||||
| 		], | ||||
| 		default: 'prompt', | ||||
| 	}, | ||||
| 	{ | ||||
| 		displayName: 'Prompt', | ||||
| 		name: 'prompt', | ||||
| 		type: 'string', | ||||
| 		description: 'The prompt to generate completion(s) for', | ||||
| 		placeholder: 'e.g. Say this is a test', | ||||
| 		displayOptions: { | ||||
| 			show: { | ||||
| 				resource: ['text'], | ||||
| 				operation: ['complete'], | ||||
| 				inputType: ['prompt'], | ||||
| 			}, | ||||
| 		}, | ||||
| 		default: '', | ||||
| 		typeOptions: { | ||||
| 			rows: 2, | ||||
| 		}, | ||||
| 		routing: { | ||||
| 			send: { | ||||
| 				type: 'body', | ||||
| 				property: 'messages', | ||||
| 				value: '={{[{"role": "user", "content": $parameter.prompt}]}}', | ||||
| 			}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		displayName: 'Messages', | ||||
| 		name: 'messages', | ||||
| 		type: 'fixedCollection', | ||||
| 		description: 'The messages in the conversation', | ||||
| 		displayOptions: { | ||||
| 			show: { | ||||
| 				resource: ['text'], | ||||
| 				operation: ['complete'], | ||||
| 				inputType: ['messages'], | ||||
| 			}, | ||||
| 		}, | ||||
| 		default: { | ||||
| 			messagesList: [ | ||||
| 				{ | ||||
| 					role: 'user', | ||||
| 					content: '', | ||||
| 				}, | ||||
| 			], | ||||
| 		}, | ||||
| 		typeOptions: { | ||||
| 			multipleValues: true, | ||||
| 		}, | ||||
| 		options: [ | ||||
| 			{ | ||||
| 				name: 'messagesList', | ||||
| 				displayName: 'Message', | ||||
| 				values: [ | ||||
| 					{ | ||||
| 						displayName: 'Role', | ||||
| 						name: 'role', | ||||
| 						type: 'options', | ||||
| 						description: 'The role of the message author', | ||||
| 						options: [ | ||||
| 							{ | ||||
| 								name: 'System', | ||||
| 								value: 'system', | ||||
| 								description: 'A system message that sets the behavior of the assistant', | ||||
| 							}, | ||||
| 							{ | ||||
| 								name: 'User', | ||||
| 								value: 'user', | ||||
| 								description: 'A message from the user', | ||||
| 							}, | ||||
| 							{ | ||||
| 								name: 'Assistant', | ||||
| 								value: 'assistant', | ||||
| 								description: 'A message from the assistant', | ||||
| 							}, | ||||
| 						], | ||||
| 						default: 'user', | ||||
| 					}, | ||||
| 					{ | ||||
| 						displayName: 'Content', | ||||
| 						name: 'content', | ||||
| 						type: 'string', | ||||
| 						description: 'The content of the message', | ||||
| 						default: '', | ||||
| 						typeOptions: { | ||||
| 							rows: 2, | ||||
| 						}, | ||||
| 					}, | ||||
| 				], | ||||
| 			}, | ||||
| 		], | ||||
| 		routing: { | ||||
| 			send: { | ||||
| 				type: 'body', | ||||
| 				property: 'messages', | ||||
| 				value: '={{$parameter.messages.messagesList}}', | ||||
| 			}, | ||||
| 		}, | ||||
| 	}, | ||||
| ]; | ||||
| 
 | ||||
| 
 | ||||
| const sharedOperations: INodeProperties[] = [ | ||||
| 	{ | ||||
| 		displayName: 'Options', | ||||
| 		name: 'options', | ||||
| 		placeholder: 'Add option', | ||||
| 		description: 'Additional options to add', | ||||
| 		type: 'collection', | ||||
| 		default: { | ||||
| 			maxTokens: 2048, | ||||
| 			temperature: 0.7, | ||||
| 		}, | ||||
| 		displayOptions: { | ||||
| 			show: { | ||||
| 				operation: ['complete'], | ||||
| 				resource: ['text'], | ||||
| 			}, | ||||
| 		}, | ||||
| 		options: [ | ||||
| 			{ | ||||
| 				displayName: 'Maximum Number of Tokens', | ||||
| 				name: 'maxTokens', | ||||
| 				default: 2048, | ||||
| 				description: | ||||
| 					'The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).', | ||||
| 				type: 'number', | ||||
| 				displayOptions: { | ||||
| 					show: { | ||||
| 						'/operation': ['complete'], | ||||
| 					}, | ||||
| 				}, | ||||
| 				typeOptions: { | ||||
| 					maxValue: 131072, | ||||
| 					minValue: 1, | ||||
| 				}, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'max_tokens', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Max Completion Tokens', | ||||
| 				name: 'maxCompletionTokens', | ||||
| 				description: | ||||
| 					'The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.', | ||||
| 				type: 'number', | ||||
| 				default: undefined, | ||||
| 				typeOptions: { | ||||
| 					minValue: 1, | ||||
| 				}, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'max_completion_tokens', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Temperature', | ||||
| 				name: 'temperature', | ||||
| 				default: 0.7, | ||||
| 				typeOptions: { maxValue: 2, minValue: 0, numberPrecision: 2 }, | ||||
| 				description: | ||||
| 					'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.', | ||||
| 				type: 'number', | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'temperature', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Top P', | ||||
| 				name: 'topP', | ||||
| 				description: | ||||
| 					'An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.', | ||||
| 				type: 'number', | ||||
| 				default: undefined, | ||||
| 				typeOptions: { | ||||
| 					maxValue: 1, | ||||
| 					minValue: 0, | ||||
| 					numberPrecision: 3, | ||||
| 				}, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'top_p', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Number of Completions', | ||||
| 				name: 'n', | ||||
| 				description: 'How many chat completion choices to generate for each input message', | ||||
| 				type: 'number', | ||||
| 				typeOptions: { | ||||
| 					minValue: 1, | ||||
| 					maxValue: 128, | ||||
| 				}, | ||||
| 				default: 1, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'n', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Stream', | ||||
| 				name: 'stream', | ||||
| 				description: 'If set, partial message deltas will be sent, like in ChatGPT', | ||||
| 				type: 'boolean', | ||||
| 				default: false, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'stream', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Stream Options', | ||||
| 				name: 'streamOptions', | ||||
| 				description: 'Options for streaming response', | ||||
| 				type: 'collection', | ||||
| 				displayOptions: { | ||||
| 					show: { | ||||
| 						stream: [true], | ||||
| 					}, | ||||
| 				}, | ||||
| 				default: {}, | ||||
| 				options: [ | ||||
| 					{ | ||||
| 						displayName: 'Include Usage', | ||||
| 						name: 'includeUsage', | ||||
| 						description: 'If set, an additional chunk will be streamed before the data: [DONE] message', | ||||
| 						type: 'boolean', | ||||
| 						default: false, | ||||
| 					}, | ||||
| 				], | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'stream_options', | ||||
| 						value: '={{$parameter.streamOptions.includeUsage ? {"include_usage": $parameter.streamOptions.includeUsage} : undefined}}', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Stop Sequences', | ||||
| 				name: 'stop', | ||||
| 				description: 'Up to 4 sequences where the API will stop generating further tokens', | ||||
| 				type: 'string', | ||||
| 				default: '', | ||||
| 				placeholder: 'e.g. \\n, Human:, AI:', | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'stop', | ||||
| 						value: '={{$parameter.stop ? $parameter.stop.split(",").map(s => s.trim()) : undefined}}', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Presence Penalty', | ||||
| 				name: 'presencePenalty', | ||||
| 				description: | ||||
| 					'Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far', | ||||
| 				type: 'number', | ||||
| 				default: undefined, | ||||
| 				typeOptions: { | ||||
| 					maxValue: 2, | ||||
| 					minValue: -2, | ||||
| 					numberPrecision: 2, | ||||
| 				}, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'presence_penalty', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Frequency Penalty', | ||||
| 				name: 'frequencyPenalty', | ||||
| 				description: | ||||
| 					'Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far', | ||||
| 				type: 'number', | ||||
| 				default: undefined, | ||||
| 				typeOptions: { | ||||
| 					maxValue: 2, | ||||
| 					minValue: -2, | ||||
| 					numberPrecision: 2, | ||||
| 				}, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'frequency_penalty', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Logprobs', | ||||
| 				name: 'logprobs', | ||||
| 				description: 'Whether to return log probabilities of the output tokens', | ||||
| 				type: 'boolean', | ||||
| 				default: false, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'logprobs', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Top Logprobs', | ||||
| 				name: 'topLogprobs', | ||||
| 				description: 'An integer between 0 and 20 specifying the number of most likely tokens to return at each token position', | ||||
| 				type: 'number', | ||||
| 				default: undefined, | ||||
| 				displayOptions: { | ||||
| 					show: { | ||||
| 						logprobs: [true], | ||||
| 					}, | ||||
| 				}, | ||||
| 				typeOptions: { | ||||
| 					minValue: 0, | ||||
| 					maxValue: 20, | ||||
| 				}, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'top_logprobs', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'User Identifier', | ||||
| 				name: 'user', | ||||
| 				description: 'A unique identifier representing your end-user, which can help monitor and detect abuse', | ||||
| 				type: 'string', | ||||
| 				default: '', | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'user', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Logit Bias', | ||||
| 				name: 'logitBias', | ||||
| 				description: 'Modify the likelihood of specified tokens appearing in the completion (JSON object mapping token IDs to bias values)', | ||||
| 				type: 'string', | ||||
| 				default: '', | ||||
| 				placeholder: '{"50256": -100}', | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'logit_bias', | ||||
| 						value: '={{$parameter.logitBias ? JSON.parse($parameter.logitBias) : undefined}}', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Metadata', | ||||
| 				name: 'metadata', | ||||
| 				description: 'Developer-defined metadata to attach to the completion (JSON object)', | ||||
| 				type: 'string', | ||||
| 				default: '', | ||||
| 				placeholder: '{"purpose": "testing"}', | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'metadata', | ||||
| 						value: '={{$parameter.metadata ? JSON.parse($parameter.metadata) : undefined}}', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Tools', | ||||
| 				name: 'tools', | ||||
| 				description: 'A list of tools the model may call', | ||||
| 				type: 'fixedCollection', | ||||
| 				typeOptions: { | ||||
| 					multipleValues: true, | ||||
| 				}, | ||||
| 				default: {}, | ||||
| 				options: [ | ||||
| 					{ | ||||
| 						name: 'toolsList', | ||||
| 						displayName: 'Tool', | ||||
| 						values: [ | ||||
| 							{ | ||||
| 								displayName: 'Type', | ||||
| 								name: 'type', | ||||
| 								type: 'options', | ||||
| 								options: [ | ||||
| 									{ | ||||
| 										name: 'Function', | ||||
| 										value: 'function', | ||||
| 									}, | ||||
| 								], | ||||
| 								default: 'function', | ||||
| 							}, | ||||
| 							{ | ||||
| 								displayName: 'Function Name', | ||||
| 								name: 'functionName', | ||||
| 								type: 'string', | ||||
| 								default: '', | ||||
| 								description: 'The name of the function to be called', | ||||
| 							}, | ||||
| 							{ | ||||
| 								displayName: 'Function Description', | ||||
| 								name: 'functionDescription', | ||||
| 								type: 'string', | ||||
| 								default: '', | ||||
| 								description: 'A description of what the function does', | ||||
| 							}, | ||||
| 							{ | ||||
| 								displayName: 'Function Parameters', | ||||
| 								name: 'functionParameters', | ||||
| 								type: 'string', | ||||
| 								description: 'The parameters the function accepts, described as a JSON Schema object', | ||||
| 								placeholder: '{"type": "object", "properties": {"location": {"type": "string"}}}', | ||||
| 								default: '', | ||||
| 							}, | ||||
| 						], | ||||
| 					}, | ||||
| 				], | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'tools', | ||||
| 						value: '={{$parameter.tools && $parameter.tools.toolsList && $parameter.tools.toolsList.length > 0 ? $parameter.tools.toolsList.map(tool => ({"type": tool.type, "function": {"name": tool.functionName, "description": tool.functionDescription, "parameters": tool.functionParameters ? JSON.parse(tool.functionParameters) : {}}})) : undefined}}', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Tool Choice', | ||||
| 				name: 'toolChoice', | ||||
| 				description: 'Controls which (if any) tool is called by the model', | ||||
| 				type: 'options', | ||||
| 				options: [ | ||||
| 					{ | ||||
| 						name: 'Auto', | ||||
| 						value: 'auto', | ||||
| 						description: 'The model can pick between generating a message or calling one or more tools', | ||||
| 					}, | ||||
| 					{ | ||||
| 						name: 'None', | ||||
| 						value: 'none', | ||||
| 						description: 'The model will not call any tool and instead generates a message', | ||||
| 					}, | ||||
| 					{ | ||||
| 						name: 'Required', | ||||
| 						value: 'required', | ||||
| 						description: 'The model must call one or more tools', | ||||
| 					}, | ||||
| 					{ | ||||
| 						name: 'Function', | ||||
| 						value: 'function', | ||||
| 						description: 'Specifies a particular tool via {"type": "function", "function": {"name": "my_function"}}', | ||||
| 					}, | ||||
| 				], | ||||
| 				default: 'auto', | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'tool_choice', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			{ | ||||
| 				displayName: 'Tool Choice Function Name', | ||||
| 				name: 'toolChoiceFunctionName', | ||||
| 				description: 'The name of the function to call when tool choice is set to function', | ||||
| 				type: 'string', | ||||
| 				default: '', | ||||
| 				displayOptions: { | ||||
| 					show: { | ||||
| 						toolChoice: ['function'], | ||||
| 					}, | ||||
| 				}, | ||||
| 				routing: { | ||||
| 					send: { | ||||
| 						type: 'body', | ||||
| 						property: 'tool_choice', | ||||
| 						value: '={{"type": "function", "function": {"name": $parameter.toolChoiceFunctionName}}}', | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		], | ||||
| 	}, | ||||
| ]; | ||||
| 
 | ||||
| export const textFields: INodeProperties[] = [ | ||||
| 	/* -------------------------------------------------------------------------- */ | ||||
| 	/*                               text:complete                        */ | ||||
| 	/* -------------------------------------------------------------------------- */ | ||||
| 	...completeOperations, | ||||
| 
 | ||||
| 	/* -------------------------------------------------------------------------- */ | ||||
| 	/*                                text:ALL                                    */ | ||||
| 	/* -------------------------------------------------------------------------- */ | ||||
| 	...sharedOperations, | ||||
| ]; | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue