chore: ran linting

This commit is contained in:
Anish Sarkar 2026-04-10 00:31:43 +05:30
parent b44c1ee034
commit 33626d4f91
6 changed files with 16 additions and 16 deletions

View file

@ -111,7 +111,9 @@ class MemoryInjectionMiddleware(AgentMiddleware): # type: ignore[type-arg]
return {"messages": new_messages} return {"messages": new_messages}
async def _load_user_memory(self, session: AsyncSession) -> tuple[str | None, str | None]: async def _load_user_memory(
self, session: AsyncSession
) -> tuple[str | None, str | None]:
"""Return (memory_content, display_name).""" """Return (memory_content, display_name)."""
try: try:
result = await session.execute( result = await session.execute(

View file

@ -134,7 +134,9 @@ async def _forced_rewrite(content: str, llm: Any) -> str | None:
Returns the rewritten string, or ``None`` if the call fails. Returns the rewritten string, or ``None`` if the call fails.
""" """
try: try:
prompt = _FORCED_REWRITE_PROMPT.format(target=MEMORY_HARD_LIMIT, content=content) prompt = _FORCED_REWRITE_PROMPT.format(
target=MEMORY_HARD_LIMIT, content=content
)
response = await llm.ainvoke( response = await llm.ainvoke(
[HumanMessage(content=prompt)], [HumanMessage(content=prompt)],
config={"tags": ["surfsense:internal"]}, config={"tags": ["surfsense:internal"]},

View file

@ -359,9 +359,7 @@ async def edit_team_memory(
).strip() ).strip()
except Exception as e: except Exception as e:
logger.exception("Team memory edit LLM call failed: %s", e) logger.exception("Team memory edit LLM call failed: %s", e)
raise HTTPException( raise HTTPException(status_code=500, detail="Team memory edit failed.") from e
status_code=500, detail="Team memory edit failed."
) from e
if not updated: if not updated:
raise HTTPException(status_code=400, detail="LLM returned empty result.") raise HTTPException(status_code=400, detail="LLM returned empty result.")
@ -370,9 +368,7 @@ async def edit_team_memory(
updated_memory=updated, updated_memory=updated,
old_memory=current_memory, old_memory=current_memory,
llm=llm, llm=llm,
apply_fn=lambda content: setattr( apply_fn=lambda content: setattr(db_search_space, "shared_memory_md", content),
db_search_space, "shared_memory_md", content
),
commit_fn=session.commit, commit_fn=session.commit,
rollback_fn=session.rollback, rollback_fn=session.rollback,
label="team memory", label="team memory",

View file

@ -30,7 +30,6 @@ from sqlalchemy.orm import selectinload
from app.agents.new_chat.chat_deepagent import create_surfsense_deep_agent from app.agents.new_chat.chat_deepagent import create_surfsense_deep_agent
from app.agents.new_chat.checkpointer import get_checkpointer from app.agents.new_chat.checkpointer import get_checkpointer
from app.agents.new_chat.memory_extraction import extract_and_save_memory
from app.agents.new_chat.llm_config import ( from app.agents.new_chat.llm_config import (
AgentConfig, AgentConfig,
create_chat_litellm_from_agent_config, create_chat_litellm_from_agent_config,
@ -38,6 +37,7 @@ from app.agents.new_chat.llm_config import (
load_agent_config, load_agent_config,
load_llm_config_from_yaml, load_llm_config_from_yaml,
) )
from app.agents.new_chat.memory_extraction import extract_and_save_memory
from app.db import ( from app.db import (
ChatVisibility, ChatVisibility,
NewChatMessage, NewChatMessage,

View file

@ -106,9 +106,7 @@ export function MemoryContent() {
if (!memory) { if (!memory) {
return ( return (
<div className="flex flex-col items-center justify-center py-16 text-center"> <div className="flex flex-col items-center justify-center py-16 text-center">
<h3 className="text-base font-medium text-foreground"> <h3 className="text-base font-medium text-foreground">What does SurfSense remember?</h3>
What does SurfSense remember?
</h3>
<p className="mt-2 max-w-sm text-sm text-muted-foreground"> <p className="mt-2 max-w-sm text-sm text-muted-foreground">
Nothing yet. SurfSense picks up on your preferences and context as you chat. Nothing yet. SurfSense picks up on your preferences and context as you chat.
</p> </p>

View file

@ -18,9 +18,11 @@ import { cacheKeys } from "@/lib/query-client/cache-keys";
const MEMORY_HARD_LIMIT = 25_000; const MEMORY_HARD_LIMIT = 25_000;
const SearchSpaceSchema = z.object({ const SearchSpaceSchema = z
shared_memory_md: z.string().optional().default(""), .object({
}).passthrough(); shared_memory_md: z.string().optional().default(""),
})
.passthrough();
interface TeamMemoryManagerProps { interface TeamMemoryManagerProps {
searchSpaceId: number; searchSpaceId: number;
@ -67,7 +69,7 @@ export function TeamMemoryManager({ searchSpaceId }: TeamMemoryManagerProps) {
await baseApiService.post( await baseApiService.post(
`/api/v1/searchspaces/${searchSpaceId}/memory/edit`, `/api/v1/searchspaces/${searchSpaceId}/memory/edit`,
SearchSpaceSchema, SearchSpaceSchema,
{ body: { query } }, { body: { query } }
); );
setEditQuery(""); setEditQuery("");
await queryClient.invalidateQueries({ await queryClient.invalidateQueries({