fix(OpenAI Node): Fix issue with expressions not working with chat complete (#5609)
This commit is contained in:
@@ -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],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
14
packages/nodes-base/nodes/OpenAi/ChatFunctions.ts
Normal file
14
packages/nodes-base/nodes/OpenAi/ChatFunctions.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user