Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions backend/alembic/versions/aeda5f2df4f6_add_pinned_assistants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""add pinned assistants

Revision ID: aeda5f2df4f6
Revises: 2955778aa44c
Create Date: 2025-01-09 16:04:10.770636

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "aeda5f2df4f6"
down_revision = "2955778aa44c"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.add_column(
"user", sa.Column("pinned_assistants", postgresql.JSONB(), nullable=True)
)


def downgrade() -> None:
op.drop_column("user", "pinned_assistants")
3 changes: 3 additions & 0 deletions backend/onyx/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ class User(SQLAlchemyBaseUserTableUUID, Base):
recent_assistants: Mapped[list[dict]] = mapped_column(
postgresql.JSONB(), nullable=False, default=list, server_default="[]"
)
pinned_assistants: Mapped[list[int] | None] = mapped_column(
postgresql.JSONB(), nullable=True, default=None
)

oidc_expiry: Mapped[datetime.datetime] = mapped_column(
TIMESTAMPAware(timezone=True), nullable=True
Expand Down
3 changes: 3 additions & 0 deletions backend/onyx/document_index/vespa/shared_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ def get_vespa_http_client(no_timeout: bool = False, http2: bool = True) -> httpx
timeout=None if no_timeout else VESPA_REQUEST_TIMEOUT,
http2=http2,
)


# from onyx.document_index.vespa.shared_utils.utils import get_vespa_http_client
1 change: 1 addition & 0 deletions backend/onyx/server/documents/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def get_chunk_info(
min_chunk_ind=chunk_id,
max_chunk_ind=chunk_id,
)

inference_chunks = document_index.id_based_retrieval(
chunk_requests=[chunk_request],
filters=IndexFilters(access_control_list=user_acl_filters),
Expand Down
1 change: 1 addition & 0 deletions backend/onyx/server/manage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class UserPreferences(BaseModel):
recent_assistants: list[int] | None = None
default_model: str | None = None
auto_scroll: bool | None = None
pinned_assistants: list[int] | None = None


class UserInfo(BaseModel):
Expand Down
41 changes: 41 additions & 0 deletions backend/onyx/server/manage/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,47 @@ def update_user_default_model(
db_session.commit()


class PinnedAssistantsRequest(BaseModel):
assistant_id: int


@router.patch("/user/pinned-assistants/{assistant_id}")
def update_user_pinned_assistants(
assistant_id: int,
pinned: bool,
user: User | None = Depends(current_user),
db_session: Session = Depends(get_session),
) -> None:
if user is None:
if AUTH_TYPE == AuthType.DISABLED:
store = get_kv_store()
no_auth_user = fetch_no_auth_user(store)
pinned_assistants = no_auth_user.preferences.pinned_assistants or []
if pinned and assistant_id not in pinned_assistants:
pinned_assistants.append(assistant_id)
elif not pinned and assistant_id in pinned_assistants:
pinned_assistants.remove(assistant_id)
no_auth_user.preferences.pinned_assistants = pinned_assistants
set_no_auth_user_preferences(store, no_auth_user.preferences)
return
else:
raise RuntimeError("This should never happen")

pinned_assistants = UserInfo.from_model(user).preferences.pinned_assistants or []
if pinned:
if assistant_id not in pinned_assistants:
pinned_assistants.append(assistant_id)
else:
if assistant_id in pinned_assistants:
pinned_assistants.remove(assistant_id)
db_session.execute(
update(User)
.where(User.id == user.id) # type: ignore
.values(pinned_assistants=pinned_assistants)
)
db_session.commit()


class ChosenAssistantsRequest(BaseModel):
chosen_assistants: list[int]

Expand Down
6 changes: 0 additions & 6 deletions node_modules/.package-lock.json

This file was deleted.

183 changes: 183 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"react-datepicker": "^7.6.0"
},
"devDependencies": {
"@types/react-datepicker": "^6.2.0"
}
}
17 changes: 11 additions & 6 deletions web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const cspHeader = `
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
${
process.env.NEXT_PUBLIC_CLOUD_ENABLED === "true"
? "upgrade-insecure-requests;"
Expand All @@ -27,6 +26,17 @@ const nextConfig = {
publicRuntimeConfig: {
version,
},
images: {
// Used to fetch favicons
remotePatterns: [
{
protocol: "https",
hostname: "www.google.com",
port: "",
pathname: "/s2/favicons/**",
},
],
},
async headers() {
return [
{
Expand All @@ -44,17 +54,12 @@ const nextConfig = {
key: "Referrer-Policy",
value: "strict-origin-when-cross-origin",
},
{
key: "X-Frame-Options",
value: "DENY",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Permissions-Policy",
// Deny all permissions by default
value:
"accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), cross-origin-isolated=(), display-capture=(), document-domain=(), encrypted-media=(), execution-while-not-rendered=(), execution-while-out-of-viewport=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), navigation-override=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()",
},
Expand Down
Loading