From cb8e76e27e2d9bba9231f9a7c9fd7e0191ae1b6f Mon Sep 17 00:00:00 2001 From: Dustin Healy Date: Sat, 13 Sep 2025 12:49:44 -0700 Subject: [PATCH] feat: add modelHistory to conversations modelHistory keeps track of all the models and their respective endpoints that are used in a conversation, so we can quickly fetch the right values to populate our cost table whenever we load a conversation rather than having to recompute the list every time --- packages/data-provider/src/schemas.ts | 1 + packages/data-schemas/src/schema/defaults.ts | 10 ++++++++++ packages/data-schemas/src/types/convo.ts | 1 + 3 files changed, 12 insertions(+) diff --git a/packages/data-provider/src/schemas.ts b/packages/data-provider/src/schemas.ts index 8ae503ef25..966e330620 100644 --- a/packages/data-provider/src/schemas.ts +++ b/packages/data-provider/src/schemas.ts @@ -631,6 +631,7 @@ export const tConversationSchema = z.object({ modelLabel: z.string().nullable().optional(), userLabel: z.string().optional(), model: z.string().nullable().optional(), + modelHistory: z.array(z.object({ model: z.string(), endpoint: z.string() })).optional(), promptPrefix: z.string().nullable().optional(), temperature: z.number().nullable().optional(), topP: z.number().optional(), diff --git a/packages/data-schemas/src/schema/defaults.ts b/packages/data-schemas/src/schema/defaults.ts index 43ac33b34d..5d8d883ac7 100644 --- a/packages/data-schemas/src/schema/defaults.ts +++ b/packages/data-schemas/src/schema/defaults.ts @@ -155,4 +155,14 @@ export const conversationPreset = { verbosity: { type: String, }, + /** Track all unique models used in this conversation with their endpoints */ + modelHistory: { + type: [ + { + model: { type: String, required: true }, + endpoint: { type: String, required: true }, + }, + ], + default: [], + }, }; diff --git a/packages/data-schemas/src/types/convo.ts b/packages/data-schemas/src/types/convo.ts index 9e77dc905b..939048287d 100644 --- a/packages/data-schemas/src/types/convo.ts +++ b/packages/data-schemas/src/types/convo.ts @@ -11,6 +11,7 @@ export interface IConversation extends Document { endpoint?: string; endpointType?: string; model?: string; + modelHistory?: Array<{ model: string; endpoint: string }>; region?: string; chatGptLabel?: string; examples?: unknown[];