2023-01-27 03:22:44 -08:00
|
|
|
import type { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
2024-08-29 06:55:53 -07:00
|
|
|
import { NodeConnectionType } from 'n8n-workflow';
|
2024-03-26 06:22:57 -07:00
|
|
|
import { oldVersionNotice } from '../../utils/descriptions';
|
2022-12-15 16:05:42 -08:00
|
|
|
import { imageFields, imageOperations } from './ImageDescription';
|
|
|
|
import { textFields, textOperations } from './TextDescription';
|
2023-03-02 06:17:29 -08:00
|
|
|
import { chatFields, chatOperations } from './ChatDescription';
|
2022-12-15 16:05:42 -08:00
|
|
|
|
|
|
|
export class OpenAi implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'OpenAI',
|
|
|
|
name: 'openAi',
|
2024-02-15 00:15:58 -08:00
|
|
|
hidden: true,
|
2024-06-06 04:34:30 -07:00
|
|
|
icon: { light: 'file:openAi.svg', dark: 'file:openAi.dark.svg' },
|
2022-12-15 16:05:42 -08:00
|
|
|
group: ['transform'],
|
2024-01-15 05:13:38 -08:00
|
|
|
version: [1, 1.1],
|
2022-12-15 16:05:42 -08:00
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
description: 'Consume Open AI',
|
|
|
|
defaults: {
|
|
|
|
name: 'OpenAI',
|
|
|
|
},
|
2024-08-29 06:55:53 -07:00
|
|
|
inputs: [NodeConnectionType.Main],
|
|
|
|
outputs: [NodeConnectionType.Main],
|
2022-12-15 16:05:42 -08:00
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'openAiApi',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
requestDefaults: {
|
2023-05-18 07:20:56 -07:00
|
|
|
ignoreHttpStatusErrors: true,
|
2022-12-15 16:05:42 -08:00
|
|
|
baseURL: 'https://api.openai.com',
|
|
|
|
},
|
|
|
|
properties: [
|
2024-02-15 00:15:58 -08:00
|
|
|
oldVersionNotice,
|
2022-12-15 16:05:42 -08:00
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
|
|
|
noDataExpression: true,
|
|
|
|
options: [
|
2023-03-02 06:17:29 -08:00
|
|
|
{
|
|
|
|
name: 'Chat',
|
|
|
|
value: 'chat',
|
|
|
|
},
|
2022-12-15 16:05:42 -08:00
|
|
|
{
|
|
|
|
name: 'Image',
|
|
|
|
value: 'image',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Text',
|
|
|
|
value: 'text',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'text',
|
|
|
|
},
|
|
|
|
|
2023-03-02 06:17:29 -08:00
|
|
|
...chatOperations,
|
|
|
|
...chatFields,
|
|
|
|
|
2022-12-15 16:05:42 -08:00
|
|
|
...imageOperations,
|
|
|
|
...imageFields,
|
|
|
|
|
|
|
|
...textOperations,
|
|
|
|
...textFields,
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|