mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
enchance ai
This commit is contained in:
@@ -43,7 +43,7 @@ export class AiComposableChart extends AIPlugin<['createComposableChart']> {
|
||||
},
|
||||
color: {
|
||||
type: 'string',
|
||||
description: 'Color used to represent the dataset'
|
||||
description: 'Color used to represent the dataset in format "#RRGGBB"'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EventModel } from "@schema/metrics/EventSchema";
|
||||
import { executeTimelineAggregation, fillAndMergeTimelineAggregationV2 } from "~/server/services/TimelineService";
|
||||
import { AdvancedTimelineAggregationOptions, executeAdvancedTimelineAggregation, executeTimelineAggregation, fillAndMergeTimelineAggregationV2 } from "~/server/services/TimelineService";
|
||||
import { Types } from "mongoose";
|
||||
import { AIPlugin, AIPlugin_TTool } from "../Plugin";
|
||||
|
||||
@@ -32,6 +32,8 @@ const getEventsTimelineTool: AIPlugin_TTool<'getEventsTimeline'> = {
|
||||
properties: {
|
||||
from: { type: 'string', description: 'ISO string of start date including hours' },
|
||||
to: { type: 'string', description: 'ISO string of end date including hours' },
|
||||
name: { type: 'string', description: 'Name of the events to get' },
|
||||
metadata: { type: 'object', description: 'Metadata of events to get' },
|
||||
},
|
||||
required: ['from', 'to']
|
||||
}
|
||||
@@ -60,12 +62,17 @@ export class AiEvents extends AIPlugin<['getEventsCount', 'getEventsTimeline']>
|
||||
tool: getEventsCountTool
|
||||
},
|
||||
'getEventsTimeline': {
|
||||
handler: async (data: { project_id: string, from: string, to: string }) => {
|
||||
const timelineData = await executeTimelineAggregation({
|
||||
handler: async (data: { project_id: string, from: string, to: string, name?: string, metadata?: string }) => {
|
||||
const query: AdvancedTimelineAggregationOptions & { customMatch: Record<string, any> } = {
|
||||
projectId: new Types.ObjectId(data.project_id) as any,
|
||||
model: EventModel,
|
||||
from: data.from, to: data.to, slice: 'day'
|
||||
});
|
||||
from: data.from, to: data.to, slice: 'day',
|
||||
customMatch: {}
|
||||
}
|
||||
if (data.metadata) query.customMatch.metadata = data.metadata;
|
||||
if (data.name) query.customMatch.name = data.name;
|
||||
|
||||
const timelineData = await executeAdvancedTimelineAggregation(query);
|
||||
const timelineFilledMerged = fillAndMergeTimelineAggregationV2(timelineData, 'day', data.from, data.to);
|
||||
return { data: timelineFilledMerged };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user