n8n/packages/nodes-base/nodes/OpenAi/OpenAi.node.ts
Jan Oberhauser 7a984bb6b7
feat(OpenAI Node): Add a node to work with OpenAI (#4932)
* feat(OpenAI Node): Add a node to work with OpenAI

* Added codex file for OpenAi node

* Minor tweaks to Operation Image.

* Minor tweaks to Resource Text.

* Minor copy modification to Image:Create.

* Removed "a Text" in Text operations names.

*  Connect Response Format parameter and other improvements

*  Add "filter" postReceiveAction

*  Rename operations and add spelling mistake again to example

*  Rename another operation

Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
Co-authored-by: Giulio Andreini <andreini@netseven.it>
2022-12-16 01:05:42 +01:00

55 lines
1.1 KiB
TypeScript

import { INodeType, INodeTypeDescription } from 'n8n-workflow';
import { imageFields, imageOperations } from './ImageDescription';
import { textFields, textOperations } from './TextDescription';
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: [
{
name: 'Image',
value: 'image',
},
{
name: 'Text',
value: 'text',
},
],
default: 'text',
},
...imageOperations,
...imageFields,
...textOperations,
...textFields,
],
};
}