feat: v1 — persistent shell, model gateway, artifact improvements (#1462)
This commit is contained in:
parent
3651670fb9
commit
f9652b452a
161 changed files with 5166 additions and 8009 deletions
|
|
@ -1,7 +1,14 @@
|
|||
import { getSession } from "@/lib/auth";
|
||||
import { z } from "zod";
|
||||
import { auth } from "@/app/(auth)/auth";
|
||||
import { getChatById, getVotesByChatId, voteMessage } from "@/lib/db/queries";
|
||||
import { ChatbotError } from "@/lib/errors";
|
||||
|
||||
const voteSchema = z.object({
|
||||
chatId: z.string(),
|
||||
messageId: z.string(),
|
||||
type: z.enum(["up", "down"]),
|
||||
});
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const chatId = searchParams.get("chatId");
|
||||
|
|
@ -13,7 +20,7 @@ export async function GET(request: Request) {
|
|||
).toResponse();
|
||||
}
|
||||
|
||||
const session = await getSession();
|
||||
const session = await auth();
|
||||
|
||||
if (!session?.user) {
|
||||
return new ChatbotError("unauthorized:vote").toResponse();
|
||||
|
|
@ -35,21 +42,23 @@ export async function GET(request: Request) {
|
|||
}
|
||||
|
||||
export async function PATCH(request: Request) {
|
||||
const {
|
||||
chatId,
|
||||
messageId,
|
||||
type,
|
||||
}: { chatId: string; messageId: string; type: "up" | "down" } =
|
||||
await request.json();
|
||||
let chatId: string;
|
||||
let messageId: string;
|
||||
let type: "up" | "down";
|
||||
|
||||
if (!chatId || !messageId || !type) {
|
||||
try {
|
||||
const parsed = voteSchema.parse(await request.json());
|
||||
chatId = parsed.chatId;
|
||||
messageId = parsed.messageId;
|
||||
type = parsed.type;
|
||||
} catch {
|
||||
return new ChatbotError(
|
||||
"bad_request:api",
|
||||
"Parameters chatId, messageId, and type are required."
|
||||
).toResponse();
|
||||
}
|
||||
|
||||
const session = await getSession();
|
||||
const session = await auth();
|
||||
|
||||
if (!session?.user) {
|
||||
return new ChatbotError("unauthorized:vote").toResponse();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue