Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions alembic/versions/90e1564bb31d_hide_extra_web_search_details.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Hide Extra Web Search details

Revision ID: 90e1564bb31d
Revises: 838ea0f68a2e
Create Date: 2025-11-24 14:17:28.920970

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "90e1564bb31d"
down_revision: Union[str, None] = "838ea0f68a2e"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"assistants",
sa.Column(
"hide_web_search_sources",
sa.Boolean(),
server_default="false",
nullable=True,
),
)
op.add_column(
"assistants",
sa.Column(
"hide_web_search_actions",
sa.Boolean(),
server_default="false",
nullable=True,
),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("assistants", "hide_web_search_actions")
op.drop_column("assistants", "hide_web_search_sources")
# ### end Alembic commands ###
24 changes: 21 additions & 3 deletions pingpong/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,8 @@ def __init__(
show_file_search_result_quotes: bool | None = None,
show_file_search_document_names: bool | None = None,
show_file_search_queries: bool | None = None,
show_web_search_sources: bool | None = None,
show_web_search_actions: bool | None = None,
show_reasoning_summaries: bool | None = None,
*args,
**kwargs,
Expand Down Expand Up @@ -905,6 +907,12 @@ def __init__(
self.show_reasoning_summaries = (
show_reasoning_summaries if show_reasoning_summaries is not None else False
)
self.show_web_search_sources = (
show_web_search_sources if show_web_search_sources is not None else True
)
self.show_web_search_actions = (
show_web_search_actions if show_web_search_actions is not None else True
)

def enqueue(self, data: Dict) -> None:
self.__buffer.write(orjson.dumps(data))
Expand Down Expand Up @@ -1755,7 +1763,9 @@ def get_action_payload(
return {
"type": WebSearchActionType.SEARCH.value,
"query": action.query,
"sources": [{"url": source.url} for source in action.sources or []],
"sources": [{"url": source.url} for source in action.sources or []]
if self.show_web_search_sources
else [],
}
case "find":
return {
Expand Down Expand Up @@ -1817,7 +1827,9 @@ async def add_cached_tool_call_on_web_search_call_created(
"output_index": self.prev_output_index,
"type": "web_search",
"web_search": {
"action": self.get_action_payload(data.action),
"action": self.get_action_payload(data.action)
if self.show_web_search_actions
else None,
},
},
}
Expand Down Expand Up @@ -2014,7 +2026,9 @@ async def add_cached_tool_call_on_web_search_call_done(
"index": self.prev_output_index,
"run_id": str(self.run_id),
"status": data.status,
"action": self.get_action_payload(data.action),
"action": self.get_action_payload(data.action)
if self.show_web_search_actions
else None,
},
}
)
Expand Down Expand Up @@ -2750,6 +2764,8 @@ async def run_response(
show_file_search_result_quotes: bool | None = None,
show_file_search_document_names: bool | None = None,
show_file_search_queries: bool | None = None,
show_web_search_sources: bool | None = None,
show_web_search_actions: bool | None = None,
show_reasoning_summaries: bool | None = None,
user_auth: str | None = None,
anonymous_link_auth: str | None = None,
Expand Down Expand Up @@ -2873,6 +2889,8 @@ async def run_response(
show_file_search_queries=show_file_search_queries,
show_file_search_result_quotes=show_file_search_result_quotes,
show_file_search_document_names=show_file_search_document_names,
show_web_search_sources=show_web_search_sources,
show_web_search_actions=show_web_search_actions,
show_reasoning_summaries=show_reasoning_summaries,
user_id=run.creator_id,
user_auth=user_auth,
Expand Down
2 changes: 2 additions & 0 deletions pingpong/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ async def copy_assistant(
hide_file_search_result_quotes=assistant.hide_file_search_result_quotes,
hide_file_search_document_names=assistant.hide_file_search_document_names,
hide_file_search_queries=assistant.hide_file_search_queries,
hide_web_search_sources=assistant.hide_web_search_sources,
hide_web_search_actions=assistant.hide_web_search_actions,
)

session.add(new_assistant)
Expand Down
2 changes: 2 additions & 0 deletions pingpong/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,8 @@ class Assistant(Base):
hide_file_search_result_quotes = Column(Boolean, server_default="true")
hide_file_search_document_names = Column(Boolean, server_default="false")
hide_file_search_queries = Column(Boolean, server_default="true")
hide_web_search_sources = Column(Boolean, server_default="false")
hide_web_search_actions = Column(Boolean, server_default="false")
class_id = Column(Integer, ForeignKey("classes.id"))
class_ = relationship("Class", back_populates="assistants", foreign_keys=[class_id])
threads = relationship("Thread", back_populates="assistant")
Expand Down
6 changes: 6 additions & 0 deletions pingpong/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ class Assistant(BaseModel):
hide_file_search_result_quotes: bool | None = None
hide_file_search_document_names: bool | None = None
hide_file_search_queries: bool | None = None
hide_web_search_sources: bool | None = None
hide_web_search_actions: bool | None = None
use_latex: bool | None
use_image_descriptions: bool | None
hide_prompt: bool | None
Expand Down Expand Up @@ -490,6 +492,8 @@ class CreateAssistant(BaseModel):
hide_file_search_result_quotes: bool = True
hide_file_search_document_names: bool = False
hide_file_search_queries: bool = True
hide_web_search_sources: bool = False
hide_web_search_actions: bool = False
deleted_private_files: list[int] = []
create_classic_assistant: bool = False

Expand Down Expand Up @@ -534,6 +538,8 @@ class UpdateAssistant(BaseModel):
hide_file_search_result_quotes: bool | None = None
hide_file_search_document_names: bool | None = None
hide_file_search_queries: bool | None = None
hide_web_search_sources: bool | None = None
hide_web_search_actions: bool | None = None
use_image_descriptions: bool | None = None
deleted_private_files: list[int] = []

Expand Down
63 changes: 59 additions & 4 deletions pingpong/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,12 @@ async def get_thread(
show_file_search_document_names = is_supervisor or (
assistant and not assistant.hide_file_search_document_names
)
show_web_search_sources = is_supervisor or (
assistant and not assistant.hide_web_search_sources
)
show_web_search_actions = is_supervisor or (
assistant and not assistant.hide_web_search_actions
)

thread_messages: list[schemas.ThreadMessage] = []
placeholder_ci_calls = []
Expand Down Expand Up @@ -2596,7 +2602,7 @@ async def get_thread(
elif tool_call.type == schemas.ToolCallType.WEB_SEARCH:
action = (
tool_call.web_search_actions[0]
if tool_call.web_search_actions
if tool_call.web_search_actions and show_web_search_actions
else None
)

Expand All @@ -2610,7 +2616,7 @@ async def get_thread(
ActionSearchSource(url=source.url or "", type="url")
for source in action.sources
]
if action and action.sources
if action and action.sources and show_web_search_sources
else []
)
action_obj = ActionSearch(
Expand Down Expand Up @@ -3428,6 +3434,12 @@ async def get_assistant(
show_file_search_document_names = is_supervisor or (
assistant and not assistant.hide_file_search_document_names
)
show_web_search_sources = is_supervisor or (
assistant and not assistant.hide_web_search_sources
)
show_web_search_actions = is_supervisor or (
assistant and not assistant.hide_web_search_actions
)

thread_messages: list[schemas.ThreadMessage] = []
placeholder_ci_calls = []
Expand Down Expand Up @@ -3518,7 +3530,7 @@ async def get_assistant(
elif tool_call.type == schemas.ToolCallType.WEB_SEARCH:
action = (
tool_call.web_search_actions[0]
if tool_call.web_search_actions
if tool_call.web_search_actions and show_web_search_actions
else None
)

Expand All @@ -3532,7 +3544,7 @@ async def get_assistant(
ActionSearchSource(url=source.url or "", type="url")
for source in action.sources
]
if action and action.sources
if action and action.sources and show_web_search_sources
else []
)
action_obj = ActionSearch(
Expand Down Expand Up @@ -4922,6 +4934,10 @@ async def get_vector_store_id_by_id_or_none(
or not asst.hide_file_search_result_quotes,
show_reasoning_summaries=is_supervisor
or not asst.hide_reasoning_summaries,
show_web_search_sources=is_supervisor
or not asst.hide_web_search_sources,
show_web_search_actions=is_supervisor
or not asst.hide_web_search_actions,
)
except Exception as e:
logger.exception("Error running thread")
Expand Down Expand Up @@ -5326,6 +5342,12 @@ async def empty_file_list() -> list[models.File]:
show_file_search_document_names = is_supervisor or (
asst and not asst.hide_file_search_document_names
)
show_web_search_sources = is_supervisor or (
asst and not asst.hide_web_search_sources
)
show_web_search_actions = is_supervisor or (
asst and not asst.hide_web_search_actions
)

messageContentParts: list[models.MessagePart] = []
part_index = 0
Expand Down Expand Up @@ -5399,6 +5421,8 @@ async def empty_file_list() -> list[models.File]:
show_file_search_queries=show_file_search_queries,
show_file_search_result_quotes=show_file_search_result_quotes,
show_file_search_document_names=show_file_search_document_names,
show_web_search_sources=show_web_search_sources,
show_web_search_actions=show_web_search_actions,
user_auth=request.state.auth_user
if hasattr(request.state, "auth_user")
else None,
Expand Down Expand Up @@ -5951,6 +5975,12 @@ async def create_assistant(
detail="Cannot hide document names while showing result quotes. Please enable 'Hide File Search Result Quotes from Members' or disable 'Completely Hide File Search Results from Members'.",
)

if req.hide_web_search_actions and not req.hide_web_search_sources:
raise HTTPException(
status_code=400,
detail="Cannot hide web search actions while showing sources. Please enable 'Hide Web Search Sources from Members' or disable 'Completely Hide Web Search Actions from Members'.",
)

uses_web_search = {"type": "web_search"} in req.tools
if uses_web_search and not model_record.supports_web_search:
raise HTTPException(
Expand Down Expand Up @@ -6786,6 +6816,31 @@ async def update_assistant(
):
asst.hide_file_search_queries = req.hide_file_search_queries

if (
"hide_web_search_sources" in req.model_fields_set
and req.hide_web_search_sources is not None
):
asst.hide_web_search_sources = req.hide_web_search_sources

if (
"hide_web_search_actions" in req.model_fields_set
and req.hide_web_search_actions is not None
):
# Validate before assignment
Comment thread
ekassos marked this conversation as resolved.
# Determine what the value of hide_web_search_sources will be after this request
new_hide_web_search_sources = (
req.hide_web_search_sources
if "hide_web_search_sources" in req.model_fields_set
and req.hide_web_search_sources is not None
else asst.hide_web_search_sources
)
if req.hide_web_search_actions and not new_hide_web_search_sources:
raise HTTPException(
status_code=400,
detail="Cannot hide web search actions while showing sources. Please enable 'Hide Web Search Sources from Members' or disable 'Completely Hide Web Search Actions from Members'.",
)
asst.hide_web_search_actions = req.hide_web_search_actions

Comment thread
ekassos marked this conversation as resolved.
if is_toggling_publish_status:
ptuple = (f"class:{class_id}#member", "can_view", f"assistant:{asst.id}")
if req.published:
Expand Down
6 changes: 6 additions & 0 deletions web/pingpong/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,8 @@ export type Assistant = {
hide_file_search_result_quotes: boolean | null;
hide_file_search_document_names: boolean | null;
hide_file_search_queries: boolean | null;
hide_web_search_sources: boolean | null;
hide_web_search_actions: boolean | null;
endorsed: boolean | null;
created: string;
updated: string | null;
Expand Down Expand Up @@ -1387,6 +1389,8 @@ export type CreateAssistantRequest = {
hide_file_search_result_quotes?: boolean;
hide_file_search_document_names?: boolean;
hide_file_search_queries?: boolean;
hide_web_search_sources?: boolean;
hide_web_search_actions?: boolean;
};

/**
Expand Down Expand Up @@ -1418,6 +1422,8 @@ export type UpdateAssistantRequest = {
hide_file_search_result_quotes?: boolean;
hide_file_search_document_names?: boolean;
hide_file_search_queries?: boolean;
hide_web_search_sources?: boolean;
hide_web_search_actions?: boolean;
};

/**
Expand Down
14 changes: 10 additions & 4 deletions web/pingpong/src/lib/components/WebSearchCallItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
</script>

<div class="my-3">
{#if content.action && content.action.type === 'search' && (uniqueSources.length > 0 || content.action.query)}
{#if content.action && content.action.type === 'search' && uniqueSources.length > 0}
<div class="flex items-center gap-2">
<GlobeOutline class="h-4 w-4 text-gray-600" />
<button class="flex flex-row items-bottom" on:click={handleClick}>
{#if content.status === 'completed'}
<span class="text-sm text-left font-medium text-gray-600"
>Searched web{content.action.query ? ` for ${content.action.query}` : ''}{#if open}<span
>Searched{content.action.query
? ` web for ${content.action.query}`
: ' the web'}{#if open}<span
>{content.action.sources
? ` across ${content.action.sources.length} ${content.action.sources.length === 1 ? 'source' : 'sources'}`
: ''}...</span
Expand Down Expand Up @@ -77,7 +79,11 @@
<div class="flex flex-row items-bottom">
{#if content.action.type === 'search'}
{#if content.status === 'completed'}
<span class="text-sm font-medium text-gray-600">Searched web</span>
<span class="text-sm font-medium text-gray-600"
>Searched{content.action.query
? ` web for ${content.action.query}`
: ' the web'}</span
>
{:else if content.status === 'failed'}
<span class="text-sm font-medium text-red-600">Web search failed</span>
{:else if content.status === 'incomplete'}
Expand Down Expand Up @@ -126,7 +132,7 @@
<GlobeOutline class="h-4 w-4 text-gray-600" />
<div class="flex flex-row items-bottom">
{#if content.status === 'completed'}
<span class="text-sm font-medium text-gray-600">Web search completed</span>
<span class="text-sm font-medium text-gray-600">Searched the web</span>
{:else if content.status === 'failed'}
<span class="text-sm font-medium text-red-600">Web search failed</span>
{:else if content.status === 'incomplete'}
Expand Down
Loading