chore: remove tokenlens and token usage tracking (#1357)

This commit is contained in:
josh 2025-12-15 16:56:10 +00:00 committed by GitHub
parent 5f9e231788
commit 7942e97095
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 60 additions and 773 deletions

View file

@ -117,8 +117,10 @@ export const updateDocumentPrompt = (
${currentContent}`;
};
export const titlePrompt = `\n
- you will generate a short title based on the first message a user begins a conversation with
- ensure it is not more than 80 characters long
- the title should be a summary of the user's message
- do not use quotes or colons`;
export const titlePrompt = `Generate a very short chat title (2-5 words max) based on the user's message.
Rules:
- Maximum 30 characters
- No quotes, colons, hashtags, or markdown
- Just the topic/intent, not a full sentence
- If the message is a greeting like "hi" or "hello", respond with just "New conversation"
- Be concise: "Weather in NYC" not "User asking about the weather in New York City"`;

View file

@ -17,7 +17,6 @@ import postgres from "postgres";
import type { ArtifactKind } from "@/components/artifact";
import type { VisibilityType } from "@/components/visibility-selector";
import { ChatSDKError } from "../errors";
import type { AppUsage } from "../usage";
import { generateUUID } from "../utils";
import {
type Chat,
@ -502,21 +501,17 @@ export async function updateChatVisibilityById({
}
}
export async function updateChatLastContextById({
export async function updateChatTitleById({
chatId,
context,
title,
}: {
chatId: string;
// Store merged server-enriched usage object
context: AppUsage;
title: string;
}) {
try {
return await db
.update(chat)
.set({ lastContext: context })
.where(eq(chat.id, chatId));
return await db.update(chat).set({ title }).where(eq(chat.id, chatId));
} catch (error) {
console.warn("Failed to update lastContext for chat", chatId, error);
console.warn("Failed to update title for chat", chatId, error);
return;
}
}

View file

@ -3,7 +3,6 @@ import {
boolean,
foreignKey,
json,
jsonb,
pgTable,
primaryKey,
text,
@ -11,7 +10,6 @@ import {
uuid,
varchar,
} from "drizzle-orm/pg-core";
import type { AppUsage } from "../usage";
export const user = pgTable("User", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
@ -31,7 +29,6 @@ export const chat = pgTable("Chat", {
visibility: varchar("visibility", { enum: ["public", "private"] })
.notNull()
.default("private"),
lastContext: jsonb("lastContext").$type<AppUsage | null>(),
});
export type Chat = InferSelectModel<typeof chat>;

View file

@ -6,7 +6,6 @@ import type { getWeather } from "./ai/tools/get-weather";
import type { requestSuggestions } from "./ai/tools/request-suggestions";
import type { updateDocument } from "./ai/tools/update-document";
import type { Suggestion } from "./db/schema";
import type { AppUsage } from "./usage";
export type DataPart = { type: "append-message"; message: string };
@ -42,7 +41,7 @@ export type CustomUIDataTypes = {
kind: ArtifactKind;
clear: null;
finish: null;
usage: AppUsage;
"chat-title": string;
};
export type ChatMessage = UIMessage<

View file

@ -1,5 +0,0 @@
import type { LanguageModelUsage } from "ai";
import type { UsageData } from "tokenlens/helpers";
// Server-merged usage: base usage + TokenLens summary + optional modelId
export type AppUsage = LanguageModelUsage & UsageData & { modelId?: string };