mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
fix chat limits update
This commit is contained in:
@@ -44,6 +44,7 @@ async function createProject() {
|
||||
await actions.setActiveProject(newActiveProjectId);
|
||||
}
|
||||
|
||||
setPageLayout('dashboard');
|
||||
router.push('/');
|
||||
|
||||
} catch (ex: any) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { sendMessageOnChat, updateChatStatus } from "~/server/services/AiService";
|
||||
import { getAiChatRemainings } from "./chats_remaining";
|
||||
import { ProjectLimitModel } from "@schema/project/ProjectsLimits";
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +16,9 @@ export default defineEventHandler(async event => {
|
||||
const chatsRemaining = await getAiChatRemainings(pid);
|
||||
if (chatsRemaining <= 0) return setResponseStatus(event, 400, 'CHAT_LIMIT_REACHED');
|
||||
|
||||
|
||||
await ProjectLimitModel.updateOne({ project_id: pid }, { $inc: { ai_messages: 1 } });
|
||||
|
||||
const currentStatus: string[] = [];
|
||||
|
||||
let responseSent = false;
|
||||
|
||||
@@ -191,7 +191,7 @@ export async function sendMessageOnChat(text: string, pid: string, time_offset:
|
||||
|
||||
if (chatMessages && chatMessages.length > 0) {
|
||||
messages.push(...chatMessages);
|
||||
await ProjectLimitModel.updateOne({ project_id: pid }, { $inc: { ai_messages: 1 } })
|
||||
|
||||
await updateChatStatus(chat_id, '', false);
|
||||
} else {
|
||||
const roleMessage: OpenAI.Chat.Completions.ChatCompletionMessageParam = {
|
||||
|
||||
Reference in New Issue
Block a user