Skip to content

Commit e942ca3

Browse files
committed
refactor: update session title model to use configured summary model and remove deprecated constant
1 parent fe1f018 commit e942ca3

4 files changed

Lines changed: 8 additions & 10 deletions

File tree

app/api/messages/sync/route.test.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
33
import { readFileSync } from "node:fs";
44
import { fileURLToPath } from "node:url";
55

6-
test("message sync summarizes every first user title with the fast mini model", () => {
6+
test("message sync summarizes every first user title with the configured summary model", () => {
77
const routeSource = readFileSync(
88
fileURLToPath(new URL("./route.ts", import.meta.url)),
99
"utf8"
@@ -17,7 +17,11 @@ test("message sync summarizes every first user title with the fast mini model",
1717
routeSource,
1818
/const\s+lastText\s*=\s*last\s*\?\s*messageText\(last\)/
1919
);
20-
assert.match(routeSource, /model:\s*openai\(SESSION_TITLE_MODEL_ID\)/);
20+
assert.match(
21+
routeSource,
22+
/import\s+\{\s*getConversationSummaryModelId\s*\}\s+from\s+"@\/lib\/ai\/openai"/
23+
);
24+
assert.match(routeSource, /model:\s*openai\(getConversationSummaryModelId\(\)\)/);
2125
assert.match(routeSource, /reasoningEffort:\s*"none"/);
2226
assert.match(routeSource, /session:\s*{\s*id:\s*sessionId,\s*\.\.\.update\s*}/);
2327
});

app/api/messages/sync/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { generateText, type UIMessage } from "ai";
22
import { openai } from "@ai-sdk/openai";
3+
import { getConversationSummaryModelId } from "@/lib/ai/openai";
34
import { persistRollingConversationSummary } from "@/lib/botchat/rolling-summary";
45
import { createSupabaseServerClient } from "@/lib/supabase/server";
56
import {
6-
SESSION_TITLE_MODEL_ID,
77
buildSessionTitlePrompt,
88
normalizeGeneratedSessionTitle,
99
shouldGenerateSessionTitle,
@@ -59,7 +59,7 @@ function messageTotalTokens(message: UIMessage) {
5959
async function buildSessionTitle(titleSource: string) {
6060
try {
6161
const { text } = await generateText({
62-
model: openai(SESSION_TITLE_MODEL_ID),
62+
model: openai(getConversationSummaryModelId()),
6363
providerOptions: {
6464
openai: {
6565
reasoningEffort: "none",

lib/botchat/session-title.test.mts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ import assert from "node:assert/strict";
44
import {
55
SESSION_TITLE_MAX_CJK_CHARACTERS,
66
SESSION_TITLE_MAX_ENGLISH_WORDS,
7-
SESSION_TITLE_MODEL_ID,
87
buildSessionTitlePrompt,
98
getOptimisticSessionTitle,
109
isSessionTitleTooLong,
1110
normalizeGeneratedSessionTitle,
1211
shouldGenerateSessionTitle,
1312
} from "./session-title.ts";
1413

15-
test("session title model is the fast mini model", () => {
16-
assert.equal(SESSION_TITLE_MODEL_ID, "gpt-5.4-mini");
17-
});
18-
1914
test("session title over-limit detection uses twelve English words", () => {
2015
assert.equal(
2116
isSessionTitleTooLong(

lib/botchat/session-title.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export const SESSION_TITLE_MODEL_ID = "gpt-5.4-mini";
21
export const SESSION_TITLE_MAX_ENGLISH_WORDS = 12;
32
export const SESSION_TITLE_MAX_CJK_CHARACTERS = 12;
43

0 commit comments

Comments
 (0)