rename openchat branding to chatbot on demo (#1421)

This commit is contained in:
dancer 2026-02-23 17:24:17 -08:00 committed by GitHub
parent 72597d6f68
commit e7ef7d8f9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 161 additions and 127 deletions

View file

@ -16,7 +16,7 @@ import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import type { ArtifactKind } from "@/components/artifact";
import type { VisibilityType } from "@/components/visibility-selector";
import { OpenChatError } from "../errors";
import { ChatbotError } from "../errors";
import { generateUUID } from "../utils";
import {
type Chat,
@ -45,7 +45,7 @@ export async function getUser(email: string): Promise<User[]> {
try {
return await db.select().from(user).where(eq(user.email, email));
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get user by email"
);
@ -58,7 +58,7 @@ export async function createUser(email: string, password: string) {
try {
return await db.insert(user).values({ email, password: hashedPassword });
} catch (_error) {
throw new OpenChatError("bad_request:database", "Failed to create user");
throw new ChatbotError("bad_request:database", "Failed to create user");
}
}
@ -72,7 +72,7 @@ export async function createGuestUser() {
email: user.email,
});
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to create guest user"
);
@ -99,7 +99,7 @@ export async function saveChat({
visibility,
});
} catch (_error) {
throw new OpenChatError("bad_request:database", "Failed to save chat");
throw new ChatbotError("bad_request:database", "Failed to save chat");
}
}
@ -115,7 +115,7 @@ export async function deleteChatById({ id }: { id: string }) {
.returning();
return chatsDeleted;
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to delete chat by id"
);
@ -146,7 +146,7 @@ export async function deleteAllChatsByUserId({ userId }: { userId: string }) {
return { deletedCount: deletedChats.length };
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to delete all chats by user id"
);
@ -189,7 +189,7 @@ export async function getChatsByUserId({
.limit(1);
if (!selectedChat) {
throw new OpenChatError(
throw new ChatbotError(
"not_found:database",
`Chat with id ${startingAfter} not found`
);
@ -204,7 +204,7 @@ export async function getChatsByUserId({
.limit(1);
if (!selectedChat) {
throw new OpenChatError(
throw new ChatbotError(
"not_found:database",
`Chat with id ${endingBefore} not found`
);
@ -222,7 +222,7 @@ export async function getChatsByUserId({
hasMore,
};
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get chats by user id"
);
@ -238,7 +238,7 @@ export async function getChatById({ id }: { id: string }) {
return selectedChat;
} catch (_error) {
throw new OpenChatError("bad_request:database", "Failed to get chat by id");
throw new ChatbotError("bad_request:database", "Failed to get chat by id");
}
}
@ -246,7 +246,7 @@ export async function saveMessages({ messages }: { messages: DBMessage[] }) {
try {
return await db.insert(message).values(messages);
} catch (_error) {
throw new OpenChatError("bad_request:database", "Failed to save messages");
throw new ChatbotError("bad_request:database", "Failed to save messages");
}
}
@ -260,7 +260,7 @@ export async function updateMessage({
try {
return await db.update(message).set({ parts }).where(eq(message.id, id));
} catch (_error) {
throw new OpenChatError("bad_request:database", "Failed to update message");
throw new ChatbotError("bad_request:database", "Failed to update message");
}
}
@ -272,7 +272,7 @@ export async function getMessagesByChatId({ id }: { id: string }) {
.where(eq(message.chatId, id))
.orderBy(asc(message.createdAt));
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get messages by chat id"
);
@ -306,7 +306,7 @@ export async function voteMessage({
isUpvoted: type === "up",
});
} catch (_error) {
throw new OpenChatError("bad_request:database", "Failed to vote message");
throw new ChatbotError("bad_request:database", "Failed to vote message");
}
}
@ -314,7 +314,7 @@ export async function getVotesByChatId({ id }: { id: string }) {
try {
return await db.select().from(vote).where(eq(vote.chatId, id));
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get votes by chat id"
);
@ -347,7 +347,7 @@ export async function saveDocument({
})
.returning();
} catch (_error) {
throw new OpenChatError("bad_request:database", "Failed to save document");
throw new ChatbotError("bad_request:database", "Failed to save document");
}
}
@ -361,7 +361,7 @@ export async function getDocumentsById({ id }: { id: string }) {
return documents;
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get documents by id"
);
@ -378,7 +378,7 @@ export async function getDocumentById({ id }: { id: string }) {
return selectedDocument;
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get document by id"
);
@ -407,7 +407,7 @@ export async function deleteDocumentsByIdAfterTimestamp({
.where(and(eq(document.id, id), gt(document.createdAt, timestamp)))
.returning();
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to delete documents by id after timestamp"
);
@ -422,7 +422,7 @@ export async function saveSuggestions({
try {
return await db.insert(suggestion).values(suggestions);
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to save suggestions"
);
@ -440,7 +440,7 @@ export async function getSuggestionsByDocumentId({
.from(suggestion)
.where(eq(suggestion.documentId, documentId));
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get suggestions by document id"
);
@ -451,7 +451,7 @@ export async function getMessageById({ id }: { id: string }) {
try {
return await db.select().from(message).where(eq(message.id, id));
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get message by id"
);
@ -491,7 +491,7 @@ export async function deleteMessagesByChatIdAfterTimestamp({
);
}
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to delete messages by chat id after timestamp"
);
@ -508,7 +508,7 @@ export async function updateChatVisibilityById({
try {
return await db.update(chat).set({ visibility }).where(eq(chat.id, chatId));
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to update chat visibility by id"
);
@ -557,7 +557,7 @@ export async function getMessageCountByUserId({
return stats?.count ?? 0;
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get message count by user id"
);
@ -576,7 +576,7 @@ export async function createStreamId({
.insert(stream)
.values({ id: streamId, chatId, createdAt: new Date() });
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to create stream id"
);
@ -594,7 +594,7 @@ export async function getStreamIdsByChatId({ chatId }: { chatId: string }) {
return streamIds.map(({ id }) => id);
} catch (_error) {
throw new OpenChatError(
throw new ChatbotError(
"bad_request:database",
"Failed to get stream ids by chat id"
);

View file

@ -34,7 +34,7 @@ export const chat = pgTable("Chat", {
export type Chat = InferSelectModel<typeof chat>;
// DEPRECATED: The following schema is deprecated and will be removed in the future.
// Read the migration guide at https://openchat.dev/docs/migration-guides/message-parts
// Read the migration guide at https://chatbot.dev/docs/migration-guides/message-parts
export const messageDeprecated = pgTable("Message", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
chatId: uuid("chatId")
@ -61,7 +61,7 @@ export const message = pgTable("Message_v2", {
export type DBMessage = InferSelectModel<typeof message>;
// DEPRECATED: The following schema is deprecated and will be removed in the future.
// Read the migration guide at https://openchat.dev/docs/migration-guides/message-parts
// Read the migration guide at https://chatbot.dev/docs/migration-guides/message-parts
export const voteDeprecated = pgTable(
"Vote",
{

View file

@ -35,7 +35,7 @@ export const visibilityBySurface: Record<Surface, ErrorVisibility> = {
activate_gateway: "response",
};
export class OpenChatError extends Error {
export class ChatbotError extends Error {
type: ErrorType;
surface: Surface;
statusCode: number;

View file

@ -8,7 +8,7 @@ import { type ClassValue, clsx } from 'clsx';
import { formatISO } from 'date-fns';
import { twMerge } from 'tailwind-merge';
import type { DBMessage, Document } from '@/lib/db/schema';
import { OpenChatError, type ErrorCode } from './errors';
import { ChatbotError, type ErrorCode } from './errors';
import type { ChatMessage, ChatTools, CustomUIDataTypes } from './types';
export function cn(...inputs: ClassValue[]) {
@ -20,7 +20,7 @@ export const fetcher = async (url: string) => {
if (!response.ok) {
const { code, cause } = await response.json();
throw new OpenChatError(code as ErrorCode, cause);
throw new ChatbotError(code as ErrorCode, cause);
}
return response.json();
@ -35,13 +35,13 @@ export async function fetchWithErrorHandlers(
if (!response.ok) {
const { code, cause } = await response.json();
throw new OpenChatError(code as ErrorCode, cause);
throw new ChatbotError(code as ErrorCode, cause);
}
return response;
} catch (error: unknown) {
if (typeof navigator !== 'undefined' && !navigator.onLine) {
throw new OpenChatError('offline:chat');
throw new ChatbotError('offline:chat');
}
throw error;