mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-10-09 20:55:06 +02:00
validated
This commit is contained in:
@@ -134,7 +134,7 @@ POSTGRES_PASSWORD = urllib.parse.quote_plus(
|
|||||||
os.environ.get("POSTGRES_PASSWORD") or "password"
|
os.environ.get("POSTGRES_PASSWORD") or "password"
|
||||||
)
|
)
|
||||||
POSTGRES_HOST = os.environ.get("POSTGRES_HOST") or "localhost"
|
POSTGRES_HOST = os.environ.get("POSTGRES_HOST") or "localhost"
|
||||||
POSTGRES_PORT = os.environ.get("POSTGRES_PORT") or "5433"
|
POSTGRES_PORT = os.environ.get("POSTGRES_PORT") or "5432"
|
||||||
POSTGRES_DB = os.environ.get("POSTGRES_DB") or "postgres"
|
POSTGRES_DB = os.environ.get("POSTGRES_DB") or "postgres"
|
||||||
|
|
||||||
POSTGRES_API_SERVER_POOL_SIZE = int(
|
POSTGRES_API_SERVER_POOL_SIZE = int(
|
||||||
|
@@ -26,8 +26,6 @@ def get_notifications_api(
|
|||||||
NotificationModel.from_model(notif)
|
NotificationModel.from_model(notif)
|
||||||
for notif in get_notifications(user, db_session, include_dismissed=False)
|
for notif in get_notifications(user, db_session, include_dismissed=False)
|
||||||
]
|
]
|
||||||
print(user)
|
|
||||||
print(len(notificatinos))
|
|
||||||
return notificatinos
|
return notificatinos
|
||||||
|
|
||||||
|
|
||||||
|
@@ -232,8 +232,6 @@ def list_personas(
|
|||||||
include_deleted: bool = False,
|
include_deleted: bool = False,
|
||||||
persona_ids: list[int] = Query(None),
|
persona_ids: list[int] = Query(None),
|
||||||
) -> list[PersonaSnapshot]:
|
) -> list[PersonaSnapshot]:
|
||||||
print("LISTING PERSONAS")
|
|
||||||
print("user", user)
|
|
||||||
personas = get_personas(
|
personas = get_personas(
|
||||||
user=user,
|
user=user,
|
||||||
include_deleted=include_deleted,
|
include_deleted=include_deleted,
|
||||||
@@ -254,7 +252,6 @@ def list_personas(
|
|||||||
and not is_image_generation_available(db_session=db_session)
|
and not is_image_generation_available(db_session=db_session)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
print(len(personas))
|
|
||||||
|
|
||||||
return [PersonaSnapshot.from_model(p) for p in personas]
|
return [PersonaSnapshot.from_model(p) for p in personas]
|
||||||
|
|
||||||
|
@@ -312,7 +312,7 @@ services:
|
|||||||
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
|
||||||
ports:
|
ports:
|
||||||
- "5433:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- db_volume:/var/lib/postgresql/data
|
- db_volume:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
@@ -312,7 +312,7 @@ services:
|
|||||||
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
|
||||||
ports:
|
ports:
|
||||||
- "5433:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- db_volume:/var/lib/postgresql/data
|
- db_volume:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
@@ -157,7 +157,7 @@ services:
|
|||||||
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
|
||||||
ports:
|
ports:
|
||||||
- "5433"
|
- "5432"
|
||||||
volumes:
|
volumes:
|
||||||
- db_volume:/var/lib/postgresql/data
|
- db_volume:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
@@ -1,6 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
|
import React, {
|
||||||
|
Dispatch,
|
||||||
|
SetStateAction,
|
||||||
|
use,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import { MinimalUserSnapshot, User } from "@/lib/types";
|
import { MinimalUserSnapshot, User } from "@/lib/types";
|
||||||
import { Persona } from "@/app/admin/assistants/interfaces";
|
import { Persona } from "@/app/admin/assistants/interfaces";
|
||||||
import { Button, Divider } from "@tremor/react";
|
import { Button, Divider } from "@tremor/react";
|
||||||
@@ -62,6 +68,7 @@ import {
|
|||||||
} from "@/lib/assistants/utils";
|
} from "@/lib/assistants/utils";
|
||||||
import { CustomTooltip } from "@/components/tooltip/CustomTooltip";
|
import { CustomTooltip } from "@/components/tooltip/CustomTooltip";
|
||||||
import { useAssistants } from "@/components/context/AssisantsContext";
|
import { useAssistants } from "@/components/context/AssisantsContext";
|
||||||
|
import { useUser } from "@/components/user/UserProvider";
|
||||||
|
|
||||||
function DraggableAssistantListItem(props: any) {
|
function DraggableAssistantListItem(props: any) {
|
||||||
const {
|
const {
|
||||||
@@ -285,27 +292,20 @@ function AssistantListItem({
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export function AssistantsList({ user }: { user: User | null }) {
|
export function AssistantsList() {
|
||||||
const { assistants } = useAssistants();
|
const {
|
||||||
// Define the distinct groups of assistants
|
assistants,
|
||||||
const { visibleAssistants, hiddenAssistants } = classifyAssistants(
|
ownedButHiddenAssistants,
|
||||||
user,
|
finalAssistants,
|
||||||
assistants
|
refreshAssistants,
|
||||||
);
|
} = useAssistants();
|
||||||
|
|
||||||
const [currentlyVisibleAssistants, setCurrentlyVisibleAssistants] = useState<
|
const [currentlyVisibleAssistants, setCurrentlyVisibleAssistants] =
|
||||||
Persona[]
|
useState(finalAssistants);
|
||||||
>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const orderedAssistants = orderAssistantsForUser(visibleAssistants, user);
|
setCurrentlyVisibleAssistants(finalAssistants);
|
||||||
setCurrentlyVisibleAssistants(orderedAssistants);
|
}, [finalAssistants]);
|
||||||
}, [assistants, user]);
|
|
||||||
|
|
||||||
const ownedButHiddenAssistants = getUserCreatedAssistants(
|
|
||||||
user,
|
|
||||||
hiddenAssistants
|
|
||||||
);
|
|
||||||
|
|
||||||
const allAssistantIds = assistants.map((assistant) =>
|
const allAssistantIds = assistants.map((assistant) =>
|
||||||
assistant.id.toString()
|
assistant.id.toString()
|
||||||
@@ -316,6 +316,8 @@ export function AssistantsList({ user }: { user: User | null }) {
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { refreshUser, user } = useUser();
|
||||||
|
|
||||||
const { popup, setPopup } = usePopup();
|
const { popup, setPopup } = usePopup();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { data: users } = useSWR<MinimalUserSnapshot[]>(
|
const { data: users } = useSWR<MinimalUserSnapshot[]>(
|
||||||
@@ -334,18 +336,22 @@ export function AssistantsList({ user }: { user: User | null }) {
|
|||||||
const { active, over } = event;
|
const { active, over } = event;
|
||||||
|
|
||||||
if (over && active.id !== over.id) {
|
if (over && active.id !== over.id) {
|
||||||
setCurrentlyVisibleAssistants((assistants) => {
|
const oldIndex = currentlyVisibleAssistants.findIndex(
|
||||||
const oldIndex = assistants.findIndex(
|
(item) => item.id.toString() === active.id
|
||||||
(a) => a.id.toString() === active.id
|
);
|
||||||
);
|
const newIndex = currentlyVisibleAssistants.findIndex(
|
||||||
const newIndex = assistants.findIndex(
|
(item) => item.id.toString() === over.id
|
||||||
(a) => a.id.toString() === over.id
|
);
|
||||||
);
|
const updatedAssistants = arrayMove(
|
||||||
const newAssistants = arrayMove(assistants, oldIndex, newIndex);
|
currentlyVisibleAssistants,
|
||||||
|
oldIndex,
|
||||||
|
newIndex
|
||||||
|
);
|
||||||
|
|
||||||
updateUserAssistantList(newAssistants.map((a) => a.id));
|
setCurrentlyVisibleAssistants(updatedAssistants);
|
||||||
return newAssistants;
|
await updateUserAssistantList(updatedAssistants.map((a) => a.id));
|
||||||
});
|
await refreshUser();
|
||||||
|
await refreshAssistants();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -101,10 +101,6 @@ import ExceptionTraceModal from "@/components/modals/ExceptionTraceModal";
|
|||||||
import { SEARCH_TOOL_NAME } from "./tools/constants";
|
import { SEARCH_TOOL_NAME } from "./tools/constants";
|
||||||
import { useUser } from "@/components/user/UserProvider";
|
import { useUser } from "@/components/user/UserProvider";
|
||||||
import { ApiKeyModal } from "@/components/llm/ApiKeyModal";
|
import { ApiKeyModal } from "@/components/llm/ApiKeyModal";
|
||||||
import {
|
|
||||||
classifyAssistants,
|
|
||||||
orderAssistantsForUser,
|
|
||||||
} from "@/lib/assistants/utils";
|
|
||||||
import BlurBackground from "./shared_chat_search/BlurBackground";
|
import BlurBackground from "./shared_chat_search/BlurBackground";
|
||||||
import { NoAssistantModal } from "@/components/modals/NoAssistantModal";
|
import { NoAssistantModal } from "@/components/modals/NoAssistantModal";
|
||||||
import { useAssistants } from "@/components/context/AssisantsContext";
|
import { useAssistants } from "@/components/context/AssisantsContext";
|
||||||
|
@@ -8,7 +8,6 @@ import {
|
|||||||
import { errorHandlingFetcher } from "@/lib/fetcher";
|
import { errorHandlingFetcher } from "@/lib/fetcher";
|
||||||
import { AssistantIcon } from "@/components/assistants/AssistantIcon";
|
import { AssistantIcon } from "@/components/assistants/AssistantIcon";
|
||||||
import { addAssistantToList } from "@/lib/assistants/updateAssistantPreferences";
|
import { addAssistantToList } from "@/lib/assistants/updateAssistantPreferences";
|
||||||
import { useChatContext } from "../context/ChatContext";
|
|
||||||
import { useAssistants } from "../context/AssisantsContext";
|
import { useAssistants } from "../context/AssisantsContext";
|
||||||
import { useUser } from "../user/UserProvider";
|
import { useUser } from "../user/UserProvider";
|
||||||
|
|
||||||
|
@@ -1,22 +1,19 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, {
|
import React, { createContext, useState, useContext, useMemo } from "react";
|
||||||
createContext,
|
|
||||||
useState,
|
|
||||||
useEffect,
|
|
||||||
useContext,
|
|
||||||
useMemo,
|
|
||||||
} from "react";
|
|
||||||
import { Persona } from "@/app/admin/assistants/interfaces";
|
import { Persona } from "@/app/admin/assistants/interfaces";
|
||||||
import { User } from "@/lib/types";
|
|
||||||
import {
|
import {
|
||||||
classifyAssistants,
|
classifyAssistants,
|
||||||
orderAssistantsForUser,
|
orderAssistantsForUser,
|
||||||
|
getUserCreatedAssistants,
|
||||||
} from "@/lib/assistants/utils";
|
} from "@/lib/assistants/utils";
|
||||||
import { useUser } from "../user/UserProvider";
|
import { useUser } from "../user/UserProvider";
|
||||||
|
|
||||||
interface AssistantsContextProps {
|
interface AssistantsContextProps {
|
||||||
assistants: Persona[];
|
assistants: Persona[];
|
||||||
|
visibleAssistants: Persona[];
|
||||||
|
hiddenAssistants: Persona[];
|
||||||
finalAssistants: Persona[];
|
finalAssistants: Persona[];
|
||||||
|
ownedButHiddenAssistants: Persona[];
|
||||||
refreshAssistants: () => Promise<void>;
|
refreshAssistants: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,27 +40,48 @@ export const AssistantsProvider: React.FC<{
|
|||||||
});
|
});
|
||||||
if (!response.ok) throw new Error("Failed to fetch assistants");
|
if (!response.ok) throw new Error("Failed to fetch assistants");
|
||||||
const assistants = await response.json();
|
const assistants = await response.json();
|
||||||
console.log("ASSISTANTS ARE", assistants);
|
|
||||||
setAssistants(assistants);
|
setAssistants(assistants);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error refreshing assistants:", error);
|
console.error("Error refreshing assistants:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const { finalAssistants } = useMemo(() => {
|
const {
|
||||||
const { visibleAssistants } = classifyAssistants(user, assistants);
|
visibleAssistants,
|
||||||
console.log("VISIBLE ASSISTANTS", visibleAssistants);
|
hiddenAssistants,
|
||||||
|
finalAssistants,
|
||||||
|
ownedButHiddenAssistants,
|
||||||
|
} = useMemo(() => {
|
||||||
|
const { visibleAssistants, hiddenAssistants } = classifyAssistants(
|
||||||
|
user,
|
||||||
|
assistants
|
||||||
|
);
|
||||||
const finalAssistants = user
|
const finalAssistants = user
|
||||||
? orderAssistantsForUser(visibleAssistants, user)
|
? orderAssistantsForUser(visibleAssistants, user)
|
||||||
: visibleAssistants;
|
: visibleAssistants;
|
||||||
console.log("FINAL ASSISTANTS", finalAssistants);
|
const ownedButHiddenAssistants = getUserCreatedAssistants(
|
||||||
return { finalAssistants };
|
user,
|
||||||
|
hiddenAssistants
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
visibleAssistants,
|
||||||
|
hiddenAssistants,
|
||||||
|
finalAssistants,
|
||||||
|
ownedButHiddenAssistants,
|
||||||
|
};
|
||||||
}, [user, assistants]);
|
}, [user, assistants]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AssistantsContext.Provider
|
<AssistantsContext.Provider
|
||||||
value={{ assistants, finalAssistants, refreshAssistants }}
|
value={{
|
||||||
|
assistants,
|
||||||
|
visibleAssistants,
|
||||||
|
hiddenAssistants,
|
||||||
|
finalAssistants,
|
||||||
|
ownedButHiddenAssistants,
|
||||||
|
refreshAssistants,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</AssistantsContext.Provider>
|
</AssistantsContext.Provider>
|
||||||
|
@@ -24,7 +24,6 @@ export function UserProvider({ children }: { children: React.ReactNode }) {
|
|||||||
try {
|
try {
|
||||||
const user = await getCurrentUser();
|
const user = await getCurrentUser();
|
||||||
setUser(user);
|
setUser(user);
|
||||||
console.log("user has been updated");
|
|
||||||
setIsAdmin(user?.role === UserRole.ADMIN);
|
setIsAdmin(user?.role === UserRole.ADMIN);
|
||||||
setIsCurator(
|
setIsCurator(
|
||||||
user?.role === UserRole.CURATOR || user?.role == UserRole.GLOBAL_CURATOR
|
user?.role === UserRole.CURATOR || user?.role == UserRole.GLOBAL_CURATOR
|
||||||
|
Reference in New Issue
Block a user