feat: add target model to messages so we dont have to peek into child ai message responses every time to know what model the user sent their message to for tokenValue computations

This commit is contained in:
Dustin Healy 2025-09-13 13:02:04 -07:00
parent 465c81adee
commit adff605c50
5 changed files with 8 additions and 0 deletions

View file

@ -233,6 +233,7 @@ class BaseClient {
sender: 'User',
text,
isCreatedByUser: true,
targetModel: this.modelOptions?.model ?? this.model,
};
}

View file

@ -88,6 +88,7 @@ async function saveUserMessage(req, params) {
parentMessageId: params.parentMessageId ?? Constants.NO_PARENT,
/* For messages, use the assistant_id instead of model */
model: params.assistant_id,
targetModel: params.model,
thread_id: params.thread_id,
sender: 'User',
text: params.text,

View file

@ -518,6 +518,7 @@ export const tMessageSchema = z.object({
overrideParentMessageId: z.string().nullable().optional(),
bg: z.string().nullable().optional(),
model: z.string().nullable().optional(),
targetModel: z.string().nullable().optional(),
title: z.string().nullable().or(z.literal('New Chat')).default('New Chat'),
sender: z.string().optional(),
text: z.string(),

View file

@ -26,6 +26,10 @@ const messageSchema: Schema<IMessage> = new Schema(
type: String,
default: null,
},
targetModel: {
type: String,
default: null,
},
endpoint: {
type: String,
},

View file

@ -7,6 +7,7 @@ export interface IMessage extends Document {
conversationId: string;
user: string;
model?: string;
targetModel?: string;
endpoint?: string;
conversationSignature?: string;
clientId?: string;