fix(editor): Adjust Ask AI tracking events & pass NDV session id (no-changelog) (#7027)

Github issue / Community forum post (link here to close automatically):

---------

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
OlegIvaniv
2023-08-29 12:53:29 +02:00
committed by GitHub
parent a4578d68a5
commit 4600bb3317
7 changed files with 48 additions and 37 deletions

View File

@@ -2,12 +2,6 @@ import type { IRestApiContext, Schema } from '@/Interface';
import { makeRestApiRequest } from '@/utils/apiUtils';
import type { IDataObject } from 'n8n-workflow';
type Usage = {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
export async function generateCodeForPrompt(
ctx: IRestApiContext,
{
@@ -20,11 +14,13 @@ export async function generateCodeForPrompt(
context: {
schema: Array<{ nodeName: string; schema: Schema }>;
inputSchema: { nodeName: string; schema: Schema };
sessionId: string;
ndvSessionId: string;
};
model: string;
n8nVersion: string;
},
): Promise<{ code: string; usage: Usage }> {
): Promise<{ code: string }> {
return makeRestApiRequest(ctx, 'POST', '/ask-ai', {
question,
context,