mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-03 16:30:21 +02:00
add pro search disable
This commit is contained in:
parent
9a3ce504bc
commit
c984c6c7f2
@ -36,6 +36,8 @@ basic_router = APIRouter(prefix="/settings")
|
||||
def put_settings(
|
||||
settings: Settings, _: User | None = Depends(current_admin_user)
|
||||
) -> None:
|
||||
print("PUTTING SETTINGS")
|
||||
print(settings)
|
||||
store_settings(settings)
|
||||
|
||||
|
||||
@ -47,7 +49,10 @@ def fetch_settings(
|
||||
) -> UserSettings:
|
||||
"""Settings and notifications are stuffed into this single endpoint to reduce number of
|
||||
Postgres calls"""
|
||||
print("FETCHING SETTINGS")
|
||||
general_settings = load_settings()
|
||||
print("LOADED SETTINGS")
|
||||
print(general_settings)
|
||||
settings_notifications = get_settings_notifications(user, db_session)
|
||||
|
||||
try:
|
||||
|
@ -45,6 +45,8 @@ class Settings(BaseModel):
|
||||
gpu_enabled: bool | None = None
|
||||
product_gating: GatingType = GatingType.NONE
|
||||
anonymous_user_enabled: bool | None = None
|
||||
pro_search_disabled: bool | None = None
|
||||
auto_scroll: bool | None = None
|
||||
|
||||
|
||||
class UserSettings(Settings):
|
||||
|
@ -11,6 +11,14 @@ logger = setup_logger()
|
||||
|
||||
|
||||
def load_settings() -> Settings:
|
||||
kv_store = get_kv_store()
|
||||
try:
|
||||
stored_settings = kv_store.load(KV_SETTINGS_KEY)
|
||||
settings = Settings(**stored_settings)
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading settings from KV store: {str(e)}")
|
||||
settings = Settings()
|
||||
|
||||
tenant_id = CURRENT_TENANT_ID_CONTEXTVAR.get() if MULTI_TENANT else None
|
||||
redis_client = get_redis_client(tenant_id=tenant_id)
|
||||
|
||||
@ -26,10 +34,10 @@ def load_settings() -> Settings:
|
||||
redis_client.set(OnyxRedisLocks.ANONYMOUS_USER_ENABLED, "0")
|
||||
except Exception as e:
|
||||
# Log the error and reset to default
|
||||
logger.error(f"Error loading settings from Redis: {str(e)}")
|
||||
logger.error(f"Error loading anonymous user setting from Redis: {str(e)}")
|
||||
anonymous_user_enabled = False
|
||||
|
||||
settings = Settings(anonymous_user_enabled=anonymous_user_enabled)
|
||||
settings.anonymous_user_enabled = anonymous_user_enabled
|
||||
return settings
|
||||
|
||||
|
||||
|
@ -228,6 +228,15 @@ export function SettingsForm() {
|
||||
}
|
||||
/>
|
||||
|
||||
<Checkbox
|
||||
label="Pro Search Disabled"
|
||||
sublabel="If set, users will not be able to use Pro Search."
|
||||
checked={settings.pro_search_disabled}
|
||||
onChange={(e) =>
|
||||
handleToggleSettingsField("pro_search_disabled", e.target.checked)
|
||||
}
|
||||
/>
|
||||
|
||||
{NEXT_PUBLIC_CLOUD_ENABLED && settings.anonymous_user_enabled && (
|
||||
<AnonymousUserPath setPopup={setPopup} />
|
||||
)}
|
||||
|
@ -10,6 +10,7 @@ export interface Settings {
|
||||
notifications: Notification[];
|
||||
needs_reindexing: boolean;
|
||||
gpu_enabled: boolean;
|
||||
pro_search_disabled: boolean;
|
||||
product_gating: GatingType;
|
||||
auto_scroll: boolean;
|
||||
}
|
||||
|
@ -1327,7 +1327,8 @@ export function ChatPage({
|
||||
systemPromptOverride:
|
||||
searchParams.get(SEARCH_PARAM_NAMES.SYSTEM_PROMPT) || undefined,
|
||||
useExistingUserMessage: isSeededChat,
|
||||
useLanggraph: proSearchEnabled,
|
||||
useLanggraph:
|
||||
!settings?.settings.pro_search_disabled && proSearchEnabled,
|
||||
});
|
||||
|
||||
const delay = (ms: number) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { FiPlusCircle, FiPlus, FiInfo, FiX, FiFilter } from "react-icons/fi";
|
||||
import { ChatInputOption } from "./ChatInputOption";
|
||||
import { Persona } from "@/app/admin/assistants/interfaces";
|
||||
@ -35,6 +35,7 @@ import { truncateString } from "@/lib/utils";
|
||||
import { buildImgUrl } from "../files/images/utils";
|
||||
import { useUser } from "@/components/user/UserProvider";
|
||||
import { AgenticToggle } from "./AgenticToggle";
|
||||
import { SettingsContext } from "@/components/settings/SettingsProvider";
|
||||
|
||||
const MAX_INPUT_HEIGHT = 200;
|
||||
export const SourceChip2 = ({
|
||||
@ -225,6 +226,7 @@ export function ChatInputBar({
|
||||
setProSearchEnabled,
|
||||
}: ChatInputBarProps) {
|
||||
const { user } = useUser();
|
||||
const settings = useContext(SettingsContext);
|
||||
useEffect(() => {
|
||||
const textarea = textAreaRef.current;
|
||||
if (textarea) {
|
||||
@ -789,12 +791,13 @@ export function ChatInputBar({
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center my-auto">
|
||||
{retrievalEnabled && (
|
||||
<AgenticToggle
|
||||
proSearchEnabled={proSearchEnabled}
|
||||
setProSearchEnabled={setProSearchEnabled}
|
||||
/>
|
||||
)}
|
||||
{retrievalEnabled &&
|
||||
!settings?.settings.pro_search_disabled && (
|
||||
<AgenticToggle
|
||||
proSearchEnabled={proSearchEnabled}
|
||||
setProSearchEnabled={setProSearchEnabled}
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
id="onyx-chat-input-send-button"
|
||||
className={`cursor-pointer ${
|
||||
|
@ -51,6 +51,7 @@ export async function fetchSettingsSS(): Promise<CombinedSettings | null> {
|
||||
notifications: [],
|
||||
needs_reindexing: false,
|
||||
anonymous_user_enabled: false,
|
||||
pro_search_disabled: false,
|
||||
};
|
||||
} else {
|
||||
throw new Error(
|
||||
@ -62,6 +63,7 @@ export async function fetchSettingsSS(): Promise<CombinedSettings | null> {
|
||||
} else {
|
||||
settings = await results[0].json();
|
||||
}
|
||||
console.log(JSON.stringify(settings));
|
||||
|
||||
let enterpriseSettings: EnterpriseSettings | null = null;
|
||||
if (tasks.length > 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user