Compare commits

...

2 Commits

Author SHA1 Message Date
pablodanswer
47bcc05863 quick nit 2025-01-10 14:52:45 -08:00
pablodanswer
46c3ab49f1 k 2025-01-10 14:40:28 -08:00
6 changed files with 31 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ from sqlalchemy import select
from sqlalchemy.orm import aliased
from sqlalchemy.orm import Session
from onyx.auth.users import anonymous_user_enabled
from onyx.configs.app_configs import DISABLE_AUTH
from onyx.configs.constants import TokenRateLimitScope
from onyx.db.models import TokenRateLimit
@@ -51,8 +52,11 @@ def _add_user_filters(
# If user is None, this is an anonymous user and we should only show public token_rate_limits
if user is None:
where_clause = TokenRateLimit.scope == TokenRateLimitScope.GLOBAL
return stmt.where(where_clause)
if anonymous_user_enabled():
where_clause = TokenRateLimit.scope == TokenRateLimitScope.GLOBAL
return stmt.where(where_clause)
else:
raise ValueError("User not authenticated")
where_clause = User__UG.user_id == user.id
if user.role == UserRole.CURATOR and get_editable:

View File

@@ -10,6 +10,7 @@ from sqlalchemy.orm import aliased
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import Session
from onyx.auth.users import anonymous_user_enabled
from onyx.configs.app_configs import DISABLE_AUTH
from onyx.configs.constants import DocumentSource
from onyx.db.connector import fetch_connector_by_id
@@ -66,8 +67,11 @@ def _add_user_filters(
# If user is None, this is an anonymous user and we should only show public cc_pairs
if user is None:
where_clause = ConnectorCredentialPair.access_type == AccessType.PUBLIC
return stmt.where(where_clause)
if anonymous_user_enabled():
where_clause = ConnectorCredentialPair.access_type == AccessType.PUBLIC
return stmt.where(where_clause)
else:
raise ValueError("User not authenticated")
where_clause = User__UG.user_id == user.id
if user.role == UserRole.CURATOR and get_editable:

View File

@@ -12,6 +12,7 @@ from sqlalchemy import select
from sqlalchemy.orm import aliased
from sqlalchemy.orm import Session
from onyx.auth.users import anonymous_user_enabled
from onyx.configs.app_configs import DISABLE_AUTH
from onyx.db.connector_credential_pair import get_cc_pair_groups_for_ids
from onyx.db.connector_credential_pair import get_connector_credential_pairs
@@ -65,8 +66,11 @@ def _add_user_filters(
# If user is None, this is an anonymous user and we should only show public DocumentSets
if user is None:
where_clause = DocumentSetDBModel.is_public == True # noqa: E712
return stmt.where(where_clause)
if anonymous_user_enabled():
where_clause = DocumentSetDBModel.is_public == True # noqa: E712
return stmt.where(where_clause)
else:
raise ValueError("User not authenticated")
where_clause = User__UserGroup.user_id == user.id
if user.role == UserRole.CURATOR and get_editable:

View File

@@ -13,6 +13,7 @@ from sqlalchemy import select
from sqlalchemy.orm import aliased
from sqlalchemy.orm import Session
from onyx.auth.users import anonymous_user_enabled
from onyx.configs.app_configs import DISABLE_AUTH
from onyx.configs.constants import MessageType
from onyx.configs.constants import SearchFeedbackType
@@ -88,8 +89,11 @@ def _add_user_filters(
# If user is None, this is an anonymous user and we should only show public documents
if user is None:
where_clause = CCPair.access_type == AccessType.PUBLIC
return stmt.where(where_clause)
if anonymous_user_enabled():
where_clause = CCPair.access_type == AccessType.PUBLIC
return stmt.where(where_clause)
else:
raise ValueError("User not authenticated")
where_clause = User__UG.user_id == user.id
if user.role == UserRole.CURATOR and get_editable:

View File

@@ -17,6 +17,7 @@ from sqlalchemy.orm import joinedload
from sqlalchemy.orm import Session
from onyx.auth.schemas import UserRole
from onyx.auth.users import anonymous_user_enabled
from onyx.configs.app_configs import DISABLE_AUTH
from onyx.configs.chat_configs import BING_API_KEY
from onyx.configs.chat_configs import CONTEXT_CHUNKS_ABOVE
@@ -82,8 +83,11 @@ def _add_user_filters(
# If user is None, this is an anonymous user and we should only show public Personas
if user is None:
where_clause = Persona.is_public == True # noqa: E712
return stmt.where(where_clause)
if anonymous_user_enabled():
where_clause = Persona.is_public == True # noqa: E712
return stmt.where(where_clause)
else:
raise ValueError("User not authenticated")
where_clause = User__UserGroup.user_id == user.id
if user.role == UserRole.CURATOR and get_editable:

View File

@@ -474,6 +474,7 @@ export function ChatPage({
const newMessageHistory = buildLatestMessageChain(newMessageMap);
// Update message history except for edge where where
// last message is an error and we're on a new chat.
// This corresponds to a "renaming" of chat, which occurs after first message
// stream