mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Start chat with public and protected agents when shared via link
This commit is contained in:
@@ -137,7 +137,9 @@ async function openChat(slug: string, userData: UserProfile | null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/chat/sessions?agent_slug=${slug}`, { method: "POST" });
|
||||
const response = await fetch(`/api/chat/sessions?agent_slug=${encodeURIComponent(slug)}`, {
|
||||
method: "POST",
|
||||
});
|
||||
const data = await response.json();
|
||||
if (response.status == 200) {
|
||||
window.location.href = `/chat?conversationId=${data.conversation_id}`;
|
||||
|
||||
@@ -826,7 +826,7 @@ class ConversationAdapters:
|
||||
user: KhojUser, client_application: ClientApplication = None, agent_slug: str = None, title: str = None
|
||||
):
|
||||
if agent_slug:
|
||||
agent = await AgentAdapters.aget_agent_by_slug(agent_slug, user)
|
||||
agent = await AgentAdapters.aget_readonly_agent_by_slug(agent_slug, user)
|
||||
if agent is None:
|
||||
raise HTTPException(status_code=400, detail="No such agent currently exists.")
|
||||
return await Conversation.objects.acreate(user=user, client=client_application, agent=agent, title=title)
|
||||
@@ -838,7 +838,7 @@ class ConversationAdapters:
|
||||
user: KhojUser, client_application: ClientApplication = None, agent_slug: str = None, title: str = None
|
||||
):
|
||||
if agent_slug:
|
||||
agent = AgentAdapters.get_agent_by_slug(agent_slug, user)
|
||||
agent = AgentAdapters.aget_readonly_agent_by_slug(agent_slug, user)
|
||||
if agent is None:
|
||||
raise HTTPException(status_code=400, detail="No such agent currently exists.")
|
||||
return Conversation.objects.create(user=user, client=client_application, agent=agent, title=title)
|
||||
|
||||
Reference in New Issue
Block a user