import { apiRequest } from "./queryClient"; import type { Chat, ChatWithMessages, Message, ChatSettings } from "@shared/schema"; export async function createChat(title: string): Promise { const res = await apiRequest("POST", "/api/chats", { title }); return res.json(); } export async function getChats(): Promise { const res = await apiRequest("GET", "/api/chats"); return res.json(); } export async function getChat(id: number): Promise { const res = await apiRequest("GET", `/api/chats/${id}`); return res.json(); } export async function deleteChat(id: number): Promise { await apiRequest("DELETE", `/api/chats/${id}`); } export async function sendMessage(chatId: number, content: string): Promise<{ userMessage: Message; aiMessage: Message; }> { const res = await apiRequest("POST", "/api/messages", { chatId, role: "user", content }); return res.json(); } export async function updateChatSettings( chatId: number, settings: Partial ): Promise { const res = await apiRequest("POST", `/api/chats/${chatId}/settings`, settings); return res.json(); }