mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 21:29:12 +00:00
Enable free tier users to have unlimited chats with the default chat model (#886)
- Allow free tier users to have unlimited chats with default chat model. It'll only be rate-limited and at the same rate as subscribed users - In the server chat settings, replace the concept of default/summarizer models with default/advanced chat models. Use the advanced models as a default for subscribed users. - For each `ChatModelOption' configuration, allow the admin to specify a separate value of `max_tokens' for subscribed users. This allows server admins to configure different max token limits for unsubscribed and subscribed users - Show error message in web app when hit rate limit or other server errors
This commit is contained in:
@@ -222,7 +222,20 @@ export default function Chat() {
|
||||
try {
|
||||
await readChatStream(response);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
// Retrieve latest message being processed
|
||||
const currentMessage = messages.find((message) => !message.completed);
|
||||
if (!currentMessage) return;
|
||||
|
||||
// Render error message as current message
|
||||
const errorMessage = (err as Error).message;
|
||||
currentMessage.rawResponse = `Encountered Error: ${errorMessage}. Please try again later.`;
|
||||
|
||||
// Complete message streaming teardown properly
|
||||
currentMessage.completed = true;
|
||||
setMessages([...messages]);
|
||||
setQueryToProcess("");
|
||||
setProcessQuerySignal(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -386,8 +386,6 @@ export default function ChatMessage(props: ChatMessageProps) {
|
||||
preElement.prepend(copyButton);
|
||||
});
|
||||
|
||||
console.log("render katex within the chat message");
|
||||
|
||||
renderMathInElement(messageRef.current, {
|
||||
delimiters: [
|
||||
{ left: "$$", right: "$$", display: true },
|
||||
|
||||
@@ -672,7 +672,15 @@ export default function SettingsView() {
|
||||
};
|
||||
|
||||
const updateModel = (name: string) => async (id: string) => {
|
||||
if (!userConfig?.is_active && name !== "search") return;
|
||||
if (!userConfig?.is_active && name !== "search") {
|
||||
toast({
|
||||
title: `Model Update`,
|
||||
description: `You need to be subscribed to update ${name} models`,
|
||||
variant: "destructive",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/model/${name}?id=` + id, {
|
||||
method: "POST",
|
||||
@@ -1144,7 +1152,7 @@ export default function SettingsView() {
|
||||
<ChatCircleText className="h-7 w-7 mr-2" />
|
||||
Chat
|
||||
</CardHeader>
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8">
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8 h-fit">
|
||||
<p className="text-gray-400">
|
||||
Pick the chat model to generate text responses
|
||||
</p>
|
||||
@@ -1169,7 +1177,7 @@ export default function SettingsView() {
|
||||
<FileMagnifyingGlass className="h-7 w-7 mr-2" />
|
||||
Search
|
||||
</CardHeader>
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8">
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8 h-fit">
|
||||
<p className="text-gray-400">
|
||||
Pick the search model to find your documents
|
||||
</p>
|
||||
@@ -1190,7 +1198,7 @@ export default function SettingsView() {
|
||||
<Palette className="h-7 w-7 mr-2" />
|
||||
Paint
|
||||
</CardHeader>
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8">
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8 h-fit">
|
||||
<p className="text-gray-400">
|
||||
Pick the paint model to generate image responses
|
||||
</p>
|
||||
@@ -1217,7 +1225,7 @@ export default function SettingsView() {
|
||||
<Waveform className="h-7 w-7 mr-2" />
|
||||
Voice
|
||||
</CardHeader>
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8">
|
||||
<CardContent className="overflow-hidden pb-12 grid gap-8 h-fit">
|
||||
<p className="text-gray-400">
|
||||
Pick the voice model to generate speech
|
||||
responses
|
||||
|
||||
Reference in New Issue
Block a user