mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-05 05:39:11 +00:00
Fix handling for new conversation in agents page
This commit is contained in:
@@ -38,6 +38,7 @@ import { getIconFromIconName } from "../common/iconUtils";
|
||||
import { convertColorToTextClass } from "../common/colorUtils";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { useIsMobileWidth } from "../common/utils";
|
||||
import { createNewConversation } from "../common/chatFunctions";
|
||||
|
||||
export interface AgentData {
|
||||
slug: string;
|
||||
@@ -55,13 +56,10 @@ async function openChat(slug: string, userData: UserProfile | null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/chat/sessions?agent_slug=${slug}`, { method: "POST" });
|
||||
const data = await response.json();
|
||||
if (response.status == 200) {
|
||||
window.location.href = `/chat?conversationId=${data.conversation_id}`;
|
||||
} else if (response.status == 403 || response.status == 401) {
|
||||
window.location.href = unauthenticatedRedirectUrl;
|
||||
} else {
|
||||
try {
|
||||
const response = await createNewConversation(slug);
|
||||
window.location.href = `/chat?v=${response.conversationUniqueId}`;
|
||||
} catch (error) {
|
||||
alert("Failed to start chat session");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user