From 0a685bda7d8b56fce55fdb77c88d6b5071e2c1f2 Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Tue, 3 Dec 2024 11:27:28 -0800 Subject: [PATCH] add comments for clarity (#3249) --- backend/danswer/db/persona.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/danswer/db/persona.py b/backend/danswer/db/persona.py index 3f3dead3d8..f8602ed5af 100644 --- a/backend/danswer/db/persona.py +++ b/backend/danswer/db/persona.py @@ -415,9 +415,6 @@ def upsert_prompt( return prompt -# NOTE: This operation cannot update persona configuration options that -# are core to the persona, such as its display priority and -# whether or not the assistant is a built-in / default assistant def upsert_persona( user: User | None, name: str, @@ -449,6 +446,12 @@ def upsert_persona( chunks_above: int = CONTEXT_CHUNKS_ABOVE, chunks_below: int = CONTEXT_CHUNKS_BELOW, ) -> Persona: + """ + NOTE: This operation cannot update persona configuration options that + are core to the persona, such as its display priority and + whether or not the assistant is a built-in / default assistant + """ + if persona_id is not None: persona = db_session.query(Persona).filter_by(id=persona_id).first() else: @@ -486,6 +489,8 @@ def upsert_persona( validate_persona_tools(tools) if persona: + # Built-in personas can only be updated through YAML configuration. + # This ensures that core system personas are not modified unintentionally. if persona.builtin_persona and not builtin_persona: raise ValueError("Cannot update builtin persona with non-builtin.") @@ -494,6 +499,9 @@ def upsert_persona( db_session=db_session, persona_id=persona.id, user=user, get_editable=True ) + # The following update excludes `default`, `built-in`, and display priority. + # Display priority is handled separately in the `display-priority` endpoint. + # `default` and `built-in` properties can only be set when creating a persona. persona.name = name persona.description = description persona.num_chunks = num_chunks