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>
This commit is contained in:
Jan Oberhauser
2022-12-15 18:05:42 -06:00
committed by GitHub
parent 3028ad3c61
commit 7a984bb6b7
9 changed files with 821 additions and 2 deletions

View File

@@ -1296,6 +1296,7 @@ export type PostReceiveAction =
response: IN8nHttpFullResponse,
) => Promise<INodeExecutionData[]>)
| IPostReceiveBinaryData
| IPostReceiveFilter
| IPostReceiveLimit
| IPostReceiveRootProperty
| IPostReceiveSet
@@ -1325,7 +1326,7 @@ export interface IPostReceiveBase {
type: string;
enabled?: boolean | string;
properties: {
[key: string]: string | number | IDataObject;
[key: string]: string | number | boolean | IDataObject;
};
errorMessage?: string;
}
@@ -1337,6 +1338,13 @@ export interface IPostReceiveBinaryData extends IPostReceiveBase {
};
}
export interface IPostReceiveFilter extends IPostReceiveBase {
type: 'filter';
properties: {
pass: boolean | string;
};
}
export interface IPostReceiveLimit extends IPostReceiveBase {
type: 'limit';
properties: {

View File

@@ -265,7 +265,6 @@ export class RoutingNode {
if (action.type === 'rootProperty') {
try {
return inputData.flatMap((item) => {
// let itemContent = item.json[action.properties.property];
let itemContent = get(item.json, action.properties.property);
if (!Array.isArray(itemContent)) {
@@ -285,6 +284,28 @@ export class RoutingNode {
});
}
}
if (action.type === 'filter') {
const passValue = action.properties.pass;
inputData = inputData.filter((item) => {
// If the value is an expression resolve it
return this.getParameterValue(
passValue,
itemIndex,
runIndex,
executeSingleFunctions.getExecuteData(),
{
$response: responseData,
$responseItem: item.json,
$value: parameterValue,
$version: this.node.typeVersion,
},
false,
) as boolean;
});
return inputData;
}
if (action.type === 'limit') {
const maxResults = this.getParameterValue(
action.properties.maxResults,