fix(OpenAI Node): Fix issue with expressions not working with chat complete (#5609)

This commit is contained in:
Jon 2023-03-03 16:08:12 +00:00 committed by GitHub
parent 2eba050461
commit e949db3525
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -1,4 +1,5 @@
import type { INodeExecutionData, INodeProperties } from 'n8n-workflow';
import { chatBodyPresend } from './ChatFunctions';
export const chatOperations: INodeProperties[] = [
{
@ -114,7 +115,7 @@ const completeOperations: INodeProperties[] = [
send: {
type: 'body',
property: 'messages',
value: '={{ $parameter.prompt.messages }}',
preSend: [chatBodyPresend],
},
},
},

View file

@ -0,0 +1,14 @@
import type { IDataObject, IExecuteSingleFunctions, IHttpRequestOptions } from 'n8n-workflow';
export async function chatBodyPresend(
this: IExecuteSingleFunctions,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
const prompts = this.getNodeParameter('prompt', '{}') as IDataObject;
requestOptions.body = Object.assign({}, requestOptions.body, {
messages: prompts.messages,
});
return requestOptions;
}