Skip to content

Commit f7b6b55

Browse files
authored
rebrand ai-chatbot to openchat across app and api (#1418)
1 parent 9d5d8a3 commit f7b6b55

File tree

17 files changed

+90
-90
lines changed

17 files changed

+90
-90
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<a href="https://chat.vercel.ai/">
2-
<img alt="Next.js 14 and App Router-ready AI chatbot." src="app/(chat)/opengraph-image.png">
3-
<h1 align="center">Chat SDK</h1>
2+
<img alt="Next.js 14 and App Router-ready OpenChat." src="app/(chat)/opengraph-image.png">
3+
<h1 align="center">OpenChat</h1>
44
</a>
55

66
<p align="center">
7-
Chat SDK is a free, open-source template built with Next.js and the AI SDK that helps you quickly build powerful chatbot applications.
7+
OpenChat (formerly AI Chatbot) is a free, open-source template built with Next.js and the AI SDK that helps you quickly build powerful chatbot applications.
88
</p>
99

1010
<p align="center">
11-
<a href="https://chat-sdk.dev"><strong>Read Docs</strong></a> ·
11+
<a href="https://openchat.dev"><strong>Read Docs</strong></a> ·
1212
<a href="#features"><strong>Features</strong></a> ·
1313
<a href="#model-providers"><strong>Model Providers</strong></a> ·
1414
<a href="#deploy-your-own"><strong>Deploy Your Own</strong></a> ·
@@ -48,13 +48,13 @@ With the [AI SDK](https://ai-sdk.dev/docs/introduction), you can also switch to
4848

4949
## Deploy Your Own
5050

51-
You can deploy your own version of the Next.js AI Chatbot to Vercel with one click:
51+
You can deploy your own version of OpenChat to Vercel with one click:
5252

53-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/templates/next.js/nextjs-ai-chatbot)
53+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/templates/next.js/openchat)
5454

5555
## Running locally
5656

57-
You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js AI Chatbot. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/projects/environment-variables) for this, but a `.env` file is all that is necessary.
57+
You will need to use the environment variables [defined in `.env.example`](.env.example) to run OpenChat. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/projects/environment-variables) for this, but a `.env` file is all that is necessary.
5858

5959
> Note: You should not commit your `.env` file or it will expose secrets that will allow others to control access to your various AI and authentication provider accounts.
6060

app/(chat)/api/chat/route.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
updateMessage,
3131
} from "@/lib/db/queries";
3232
import type { DBMessage } from "@/lib/db/schema";
33-
import { ChatSDKError } from "@/lib/errors";
33+
import { OpenChatError } from "@/lib/errors";
3434
import type { ChatMessage } from "@/lib/types";
3535
import { convertToUIMessages, generateUUID } from "@/lib/utils";
3636
import { generateTitleFromUserMessage } from "../../actions";
@@ -55,7 +55,7 @@ export async function POST(request: Request) {
5555
const json = await request.json();
5656
requestBody = postRequestBodySchema.parse(json);
5757
} catch (_) {
58-
return new ChatSDKError("bad_request:api").toResponse();
58+
return new OpenChatError("bad_request:api").toResponse();
5959
}
6060

6161
try {
@@ -65,7 +65,7 @@ export async function POST(request: Request) {
6565
const session = await auth();
6666

6767
if (!session?.user) {
68-
return new ChatSDKError("unauthorized:chat").toResponse();
68+
return new OpenChatError("unauthorized:chat").toResponse();
6969
}
7070

7171
const userType: UserType = session.user.type;
@@ -76,7 +76,7 @@ export async function POST(request: Request) {
7676
});
7777

7878
if (messageCount > entitlementsByUserType[userType].maxMessagesPerDay) {
79-
return new ChatSDKError("rate_limit:chat").toResponse();
79+
return new OpenChatError("rate_limit:chat").toResponse();
8080
}
8181

8282
const isToolApprovalFlow = Boolean(messages);
@@ -87,7 +87,7 @@ export async function POST(request: Request) {
8787

8888
if (chat) {
8989
if (chat.userId !== session.user.id) {
90-
return new ChatSDKError("forbidden:chat").toResponse();
90+
return new OpenChatError("forbidden:chat").toResponse();
9191
}
9292
if (!isToolApprovalFlow) {
9393
messagesFromDb = await getMessagesByChatId({ id });
@@ -244,7 +244,7 @@ export async function POST(request: Request) {
244244
} catch (error) {
245245
const vercelId = request.headers.get("x-vercel-id");
246246

247-
if (error instanceof ChatSDKError) {
247+
if (error instanceof OpenChatError) {
248248
return error.toResponse();
249249
}
250250

@@ -254,11 +254,11 @@ export async function POST(request: Request) {
254254
"AI Gateway requires a valid credit card on file to service requests"
255255
)
256256
) {
257-
return new ChatSDKError("bad_request:activate_gateway").toResponse();
257+
return new OpenChatError("bad_request:activate_gateway").toResponse();
258258
}
259259

260260
console.error("Unhandled error in chat API:", error, { vercelId });
261-
return new ChatSDKError("offline:chat").toResponse();
261+
return new OpenChatError("offline:chat").toResponse();
262262
}
263263
}
264264

@@ -267,19 +267,19 @@ export async function DELETE(request: Request) {
267267
const id = searchParams.get("id");
268268

269269
if (!id) {
270-
return new ChatSDKError("bad_request:api").toResponse();
270+
return new OpenChatError("bad_request:api").toResponse();
271271
}
272272

273273
const session = await auth();
274274

275275
if (!session?.user) {
276-
return new ChatSDKError("unauthorized:chat").toResponse();
276+
return new OpenChatError("unauthorized:chat").toResponse();
277277
}
278278

279279
const chat = await getChatById({ id });
280280

281281
if (chat?.userId !== session.user.id) {
282-
return new ChatSDKError("forbidden:chat").toResponse();
282+
return new OpenChatError("forbidden:chat").toResponse();
283283
}
284284

285285
const deletedChat = await deleteChatById({ id });

app/(chat)/api/document/route.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import {
55
getDocumentsById,
66
saveDocument,
77
} from "@/lib/db/queries";
8-
import { ChatSDKError } from "@/lib/errors";
8+
import { OpenChatError } from "@/lib/errors";
99

1010
export async function GET(request: Request) {
1111
const { searchParams } = new URL(request.url);
1212
const id = searchParams.get("id");
1313

1414
if (!id) {
15-
return new ChatSDKError(
15+
return new OpenChatError(
1616
"bad_request:api",
1717
"Parameter id is missing"
1818
).toResponse();
@@ -21,19 +21,19 @@ export async function GET(request: Request) {
2121
const session = await auth();
2222

2323
if (!session?.user) {
24-
return new ChatSDKError("unauthorized:document").toResponse();
24+
return new OpenChatError("unauthorized:document").toResponse();
2525
}
2626

2727
const documents = await getDocumentsById({ id });
2828

2929
const [document] = documents;
3030

3131
if (!document) {
32-
return new ChatSDKError("not_found:document").toResponse();
32+
return new OpenChatError("not_found:document").toResponse();
3333
}
3434

3535
if (document.userId !== session.user.id) {
36-
return new ChatSDKError("forbidden:document").toResponse();
36+
return new OpenChatError("forbidden:document").toResponse();
3737
}
3838

3939
return Response.json(documents, { status: 200 });
@@ -44,7 +44,7 @@ export async function POST(request: Request) {
4444
const id = searchParams.get("id");
4545

4646
if (!id) {
47-
return new ChatSDKError(
47+
return new OpenChatError(
4848
"bad_request:api",
4949
"Parameter id is required."
5050
).toResponse();
@@ -53,7 +53,7 @@ export async function POST(request: Request) {
5353
const session = await auth();
5454

5555
if (!session?.user) {
56-
return new ChatSDKError("not_found:document").toResponse();
56+
return new OpenChatError("not_found:document").toResponse();
5757
}
5858

5959
const {
@@ -69,7 +69,7 @@ export async function POST(request: Request) {
6969
const [doc] = documents;
7070

7171
if (doc.userId !== session.user.id) {
72-
return new ChatSDKError("forbidden:document").toResponse();
72+
return new OpenChatError("forbidden:document").toResponse();
7373
}
7474
}
7575

@@ -90,14 +90,14 @@ export async function DELETE(request: Request) {
9090
const timestamp = searchParams.get("timestamp");
9191

9292
if (!id) {
93-
return new ChatSDKError(
93+
return new OpenChatError(
9494
"bad_request:api",
9595
"Parameter id is required."
9696
).toResponse();
9797
}
9898

9999
if (!timestamp) {
100-
return new ChatSDKError(
100+
return new OpenChatError(
101101
"bad_request:api",
102102
"Parameter timestamp is required."
103103
).toResponse();
@@ -106,15 +106,15 @@ export async function DELETE(request: Request) {
106106
const session = await auth();
107107

108108
if (!session?.user) {
109-
return new ChatSDKError("unauthorized:document").toResponse();
109+
return new OpenChatError("unauthorized:document").toResponse();
110110
}
111111

112112
const documents = await getDocumentsById({ id });
113113

114114
const [document] = documents;
115115

116116
if (document.userId !== session.user.id) {
117-
return new ChatSDKError("forbidden:document").toResponse();
117+
return new OpenChatError("forbidden:document").toResponse();
118118
}
119119

120120
const documentsDeleted = await deleteDocumentsByIdAfterTimestamp({

app/(chat)/api/history/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { NextRequest } from "next/server";
22
import { auth } from "@/app/(auth)/auth";
33
import { deleteAllChatsByUserId, getChatsByUserId } from "@/lib/db/queries";
4-
import { ChatSDKError } from "@/lib/errors";
4+
import { OpenChatError } from "@/lib/errors";
55

66
export async function GET(request: NextRequest) {
77
const { searchParams } = request.nextUrl;
@@ -11,7 +11,7 @@ export async function GET(request: NextRequest) {
1111
const endingBefore = searchParams.get("ending_before");
1212

1313
if (startingAfter && endingBefore) {
14-
return new ChatSDKError(
14+
return new OpenChatError(
1515
"bad_request:api",
1616
"Only one of starting_after or ending_before can be provided."
1717
).toResponse();
@@ -20,7 +20,7 @@ export async function GET(request: NextRequest) {
2020
const session = await auth();
2121

2222
if (!session?.user) {
23-
return new ChatSDKError("unauthorized:chat").toResponse();
23+
return new OpenChatError("unauthorized:chat").toResponse();
2424
}
2525

2626
const chats = await getChatsByUserId({
@@ -37,7 +37,7 @@ export async function DELETE() {
3737
const session = await auth();
3838

3939
if (!session?.user) {
40-
return new ChatSDKError("unauthorized:chat").toResponse();
40+
return new OpenChatError("unauthorized:chat").toResponse();
4141
}
4242

4343
const result = await deleteAllChatsByUserId({ userId: session.user.id });

app/(chat)/api/suggestions/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { auth } from "@/app/(auth)/auth";
22
import { getSuggestionsByDocumentId } from "@/lib/db/queries";
3-
import { ChatSDKError } from "@/lib/errors";
3+
import { OpenChatError } from "@/lib/errors";
44

55
export async function GET(request: Request) {
66
const { searchParams } = new URL(request.url);
77
const documentId = searchParams.get("documentId");
88

99
if (!documentId) {
10-
return new ChatSDKError(
10+
return new OpenChatError(
1111
"bad_request:api",
1212
"Parameter documentId is required."
1313
).toResponse();
@@ -16,7 +16,7 @@ export async function GET(request: Request) {
1616
const session = await auth();
1717

1818
if (!session?.user) {
19-
return new ChatSDKError("unauthorized:suggestions").toResponse();
19+
return new OpenChatError("unauthorized:suggestions").toResponse();
2020
}
2121

2222
const suggestions = await getSuggestionsByDocumentId({
@@ -30,7 +30,7 @@ export async function GET(request: Request) {
3030
}
3131

3232
if (suggestion.userId !== session.user.id) {
33-
return new ChatSDKError("forbidden:api").toResponse();
33+
return new OpenChatError("forbidden:api").toResponse();
3434
}
3535

3636
return Response.json(suggestions, { status: 200 });

app/(chat)/api/vote/route.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { auth } from "@/app/(auth)/auth";
22
import { getChatById, getVotesByChatId, voteMessage } from "@/lib/db/queries";
3-
import { ChatSDKError } from "@/lib/errors";
3+
import { OpenChatError } from "@/lib/errors";
44

55
export async function GET(request: Request) {
66
const { searchParams } = new URL(request.url);
77
const chatId = searchParams.get("chatId");
88

99
if (!chatId) {
10-
return new ChatSDKError(
10+
return new OpenChatError(
1111
"bad_request:api",
1212
"Parameter chatId is required."
1313
).toResponse();
@@ -16,17 +16,17 @@ export async function GET(request: Request) {
1616
const session = await auth();
1717

1818
if (!session?.user) {
19-
return new ChatSDKError("unauthorized:vote").toResponse();
19+
return new OpenChatError("unauthorized:vote").toResponse();
2020
}
2121

2222
const chat = await getChatById({ id: chatId });
2323

2424
if (!chat) {
25-
return new ChatSDKError("not_found:chat").toResponse();
25+
return new OpenChatError("not_found:chat").toResponse();
2626
}
2727

2828
if (chat.userId !== session.user.id) {
29-
return new ChatSDKError("forbidden:vote").toResponse();
29+
return new OpenChatError("forbidden:vote").toResponse();
3030
}
3131

3232
const votes = await getVotesByChatId({ id: chatId });
@@ -43,7 +43,7 @@ export async function PATCH(request: Request) {
4343
await request.json();
4444

4545
if (!chatId || !messageId || !type) {
46-
return new ChatSDKError(
46+
return new OpenChatError(
4747
"bad_request:api",
4848
"Parameters chatId, messageId, and type are required."
4949
).toResponse();
@@ -52,17 +52,17 @@ export async function PATCH(request: Request) {
5252
const session = await auth();
5353

5454
if (!session?.user) {
55-
return new ChatSDKError("unauthorized:vote").toResponse();
55+
return new OpenChatError("unauthorized:vote").toResponse();
5656
}
5757

5858
const chat = await getChatById({ id: chatId });
5959

6060
if (!chat) {
61-
return new ChatSDKError("not_found:vote").toResponse();
61+
return new OpenChatError("not_found:vote").toResponse();
6262
}
6363

6464
if (chat.userId !== session.user.id) {
65-
return new ChatSDKError("forbidden:vote").toResponse();
65+
return new OpenChatError("forbidden:vote").toResponse();
6666
}
6767

6868
await voteMessage({

app/(chat)/opengraph-image.png

-128 KB
Loading

components/app-sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function AppSidebar({ user }: { user: User | undefined }) {
7272
}}
7373
>
7474
<span className="cursor-pointer rounded-md px-2 font-semibold text-lg hover:bg-muted">
75-
Chatbot
75+
OpenChat
7676
</span>
7777
</Link>
7878
<div className="flex flex-row gap-1">

components/chat-header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function PureChatHeader({
5555
className="order-3 hidden bg-zinc-900 px-2 text-zinc-50 hover:bg-zinc-800 md:ml-auto md:flex md:h-fit dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-zinc-200"
5656
>
5757
<Link
58-
href={"https://vercel.com/templates/next.js/nextjs-ai-chatbot"}
58+
href={"https://vercel.com/templates/next.js/openchat"}
5959
rel="noreferrer"
6060
target="_noblank"
6161
>

0 commit comments

Comments
 (0)