feat(chat): add admin-editable assistant system prompt
This commit is contained in:
@@ -45,3 +45,37 @@ class ChatMessage(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = ["created_at"]
|
||||
|
||||
|
||||
class ChatSystemPrompt(models.Model):
|
||||
"""Admin-editable system prompt for the travel assistant.
|
||||
|
||||
Only one instance should exist (singleton pattern via Django admin).
|
||||
The prompt text replaces the hardcoded base prompt in get_system_prompt().
|
||||
Dynamic user/party preference injection is appended automatically.
|
||||
"""
|
||||
|
||||
prompt_text = models.TextField(
|
||||
help_text="Base system prompt for the travel assistant. "
|
||||
"User and party travel preferences are appended automatically."
|
||||
)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Chat System Prompt"
|
||||
verbose_name_plural = "Chat System Prompt"
|
||||
|
||||
def __str__(self):
|
||||
return f"System Prompt (updated {self.updated_at})"
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.pk = 1
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
"""Return the singleton instance or None if not configured."""
|
||||
try:
|
||||
return cls.objects.get(pk=1)
|
||||
except cls.DoesNotExist:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user