mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(OpenAI Node): Fix issue with expressions not working with chat complete (#5609)
This commit is contained in:
parent
2eba050461
commit
e949db3525
|
@ -1,4 +1,5 @@
|
||||||
import type { INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
import type { INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
||||||
|
import { chatBodyPresend } from './ChatFunctions';
|
||||||
|
|
||||||
export const chatOperations: INodeProperties[] = [
|
export const chatOperations: INodeProperties[] = [
|
||||||
{
|
{
|
||||||
|
@ -114,7 +115,7 @@ const completeOperations: INodeProperties[] = [
|
||||||
send: {
|
send: {
|
||||||
type: 'body',
|
type: 'body',
|
||||||
property: 'messages',
|
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;
|
||||||
|
}
|
Loading…
Reference in a new issue