mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-29 17:20:44 +02:00
add comments for clarity (#3249)
This commit is contained in:
@ -415,9 +415,6 @@ def upsert_prompt(
|
|||||||
return 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(
|
def upsert_persona(
|
||||||
user: User | None,
|
user: User | None,
|
||||||
name: str,
|
name: str,
|
||||||
@ -449,6 +446,12 @@ def upsert_persona(
|
|||||||
chunks_above: int = CONTEXT_CHUNKS_ABOVE,
|
chunks_above: int = CONTEXT_CHUNKS_ABOVE,
|
||||||
chunks_below: int = CONTEXT_CHUNKS_BELOW,
|
chunks_below: int = CONTEXT_CHUNKS_BELOW,
|
||||||
) -> Persona:
|
) -> 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:
|
if persona_id is not None:
|
||||||
persona = db_session.query(Persona).filter_by(id=persona_id).first()
|
persona = db_session.query(Persona).filter_by(id=persona_id).first()
|
||||||
else:
|
else:
|
||||||
@ -486,6 +489,8 @@ def upsert_persona(
|
|||||||
validate_persona_tools(tools)
|
validate_persona_tools(tools)
|
||||||
|
|
||||||
if persona:
|
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:
|
if persona.builtin_persona and not builtin_persona:
|
||||||
raise ValueError("Cannot update builtin persona with non-builtin.")
|
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
|
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.name = name
|
||||||
persona.description = description
|
persona.description = description
|
||||||
persona.num_chunks = num_chunks
|
persona.num_chunks = num_chunks
|
||||||
|
Reference in New Issue
Block a user