2023-01-27 03:22:44 -08:00
|
|
|
import type { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
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',
|
|
|
|
icon: 'file:openAi.svg',
|
|
|
|
group: ['transform'],
|
|
|
|
version: 1,
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
description: 'Consume Open AI',
|
|
|
|
defaults: {
|
|
|
|
name: 'OpenAI',
|
|
|
|
},
|
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'openAiApi',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
requestDefaults: {
|
|
|
|
baseURL: 'https://api.openai.com',
|
|
|
|
},
|
|
|
|
properties: [
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|