Skip to content

Commit

Permalink
fix(OpenAI Node): Fix issue with expressions not working with chat co…
Browse files Browse the repository at this point in the history
…mplete (#5609)
  • Loading branch information
Joffcom authored Mar 3, 2023
1 parent 2eba050 commit e949db3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/OpenAi/ChatDescription.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { INodeExecutionData, INodeProperties } from 'n8n-workflow';
import { chatBodyPresend } from './ChatFunctions';

export const chatOperations: INodeProperties[] = [
{
Expand Down Expand Up @@ -114,7 +115,7 @@ const completeOperations: INodeProperties[] = [
send: {
type: 'body',
property: 'messages',
value: '={{ $parameter.prompt.messages }}',
preSend: [chatBodyPresend],
},
},
},
Expand Down
14 changes: 14 additions & 0 deletions packages/nodes-base/nodes/OpenAi/ChatFunctions.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit e949db3

Please sign in to comment.