MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / update_persona

Method update_persona

astrbot/core/db/sqlite.py:967–996  ·  view source on GitHub ↗

Update a persona's system prompt or begin dialogs.

(
        self,
        persona_id,
        system_prompt=None,
        begin_dialogs=None,
        tools=NOT_GIVEN,
        skills=NOT_GIVEN,
        custom_error_message=NOT_GIVEN,
    )

Source from the content-addressed store, hash-verified

965 return result.scalars().all()
966
967 async def update_persona(
968 self,
969 persona_id,
970 system_prompt=None,
971 begin_dialogs=None,
972 tools=NOT_GIVEN,
973 skills=NOT_GIVEN,
974 custom_error_message=NOT_GIVEN,
975 ):
976 """Update a persona's system prompt or begin dialogs."""
977 async with self.get_db() as session:
978 session: AsyncSession
979 async with session.begin():
980 query = update(Persona).where(col(Persona.persona_id) == persona_id)
981 values = {}
982 if system_prompt is not None:
983 values["system_prompt"] = system_prompt
984 if begin_dialogs is not None:
985 values["begin_dialogs"] = begin_dialogs
986 if tools is not NOT_GIVEN:
987 values["tools"] = tools
988 if skills is not NOT_GIVEN:
989 values["skills"] = skills
990 if custom_error_message is not NOT_GIVEN:
991 values["custom_error_message"] = custom_error_message
992 if not values:
993 return None
994 query = query.values(**values)
995 await session.execute(query)
996 return await self.get_persona_by_id(persona_id)
997
998 async def delete_persona(self, persona_id) -> None:
999 """Delete a persona by its ID."""

Callers

nothing calls this directly

Calls 5

get_persona_by_idMethod · 0.95
updateFunction · 0.50
get_dbMethod · 0.45
valuesMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected