Compare commits

...

7 Commits

Author SHA1 Message Date
pablodanswer
c26f3f4507 k 2025-01-06 17:41:19 -08:00
pablodanswer
ea01c282b7 nit 2025-01-06 16:32:15 -08:00
pablodanswer
ec5b8b240e nit 2025-01-06 16:20:35 -08:00
pablodanswer
2d948812a5 nit 2025-01-06 16:20:35 -08:00
pablodanswer
35c5bbd1aa k 2025-01-06 16:20:35 -08:00
pablodanswer
3536b5e7c7 improved 2025-01-06 16:20:35 -08:00
pablodanswer
bf48eb435c k 2025-01-06 16:20:35 -08:00
4 changed files with 26 additions and 11 deletions

View File

@@ -508,6 +508,7 @@ class Document(Base):
last_synced: Mapped[datetime.datetime | None] = mapped_column(
DateTime(timezone=True), nullable=True, index=True
)
# The following are not attached to User because the account/email may not be known
# within Onyx
# Something like the document creator

View File

@@ -151,7 +151,7 @@ def auto_add_search_tool_to_personas(db_session: Session) -> None:
logger.notice("Completed adding SearchTool to relevant Personas.")
_built_in_tools_cache: dict[int, Type[Tool]] | None = None
_built_in_tools_cache: dict[str, Type[Tool]] | None = None
def refresh_built_in_tools_cache(db_session: Session) -> None:
@@ -173,15 +173,21 @@ def refresh_built_in_tools_cache(db_session: Session) -> None:
),
None,
)
if tool_info:
_built_in_tools_cache[tool.id] = tool_info["cls"]
if tool_info and tool.in_code_tool_id:
_built_in_tools_cache[tool.in_code_tool_id] = tool_info["cls"]
def get_built_in_tool_by_id(
tool_id: int, db_session: Session, force_refresh: bool = False
in_code_tool_id: str, db_session: Session, force_refresh: bool = False
) -> Type[Tool]:
global _built_in_tools_cache
if _built_in_tools_cache is None or force_refresh:
# If the tool is not in the cache, refresh it once
if (
_built_in_tools_cache is None
or force_refresh
or in_code_tool_id not in _built_in_tools_cache
):
refresh_built_in_tools_cache(db_session)
if _built_in_tools_cache is None:
@@ -189,7 +195,9 @@ def get_built_in_tool_by_id(
"Built-in tools cache is None despite being refreshed. Should never happen."
)
if tool_id in _built_in_tools_cache:
return _built_in_tools_cache[tool_id]
else:
raise ValueError(f"No built-in tool found in the cache with ID {tool_id}")
if in_code_tool_id not in _built_in_tools_cache:
raise ValueError(
f"No built-in tool found in the cache with ID {in_code_tool_id}"
)
return _built_in_tools_cache[in_code_tool_id]

View File

@@ -148,7 +148,9 @@ def construct_tools(
for db_tool_model in persona.tools:
if db_tool_model.in_code_tool_id:
tool_cls = get_built_in_tool_by_id(db_tool_model.id, db_session)
tool_cls = get_built_in_tool_by_id(
db_tool_model.in_code_tool_id, db_session
)
# Handle Search Tool
if tool_cls.__name__ == SearchTool.__name__:

View File

@@ -14,7 +14,11 @@ const cspHeader = `
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
${process.env.NEXT_PUBLIC_CLOUD_ENABLED === "true" ? "upgrade-insecure-requests;" : ""}
${
process.env.NEXT_PUBLIC_CLOUD_ENABLED === "true"
? "upgrade-insecure-requests;"
: ""
}
`;
/** @type {import('next').NextConfig} */