You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
956 B
32 lines
956 B
from django.db import models
|
|
from django.core.cache import cache
|
|
|
|
|
|
class AgentSettings(models.Model):
|
|
# Fixed Settings
|
|
system_prompt = models.TextField(default="You are a helpful assistant.")
|
|
model_id = models.CharField(max_length=50, default="deepseek/deepseek-r1")
|
|
temperature = models.FloatField(default=0.3)
|
|
|
|
# Switches
|
|
is_maintenance_mode = models.BooleanField(default=False)
|
|
|
|
class Meta:
|
|
verbose_name = "Agent Configuration"
|
|
verbose_name_plural = "Agent Configuration"
|
|
|
|
def save(self, *args, **kwargs):
|
|
self.pk = 1
|
|
super().save(*args, **kwargs)
|
|
|
|
# Clear cache whenever you save
|
|
cache.delete("agent_config_1")
|
|
|
|
def __str__(self):
|
|
return "Global Agent Settings"
|
|
|
|
@classmethod
|
|
def load(cls):
|
|
"""Helper to get the singleton instance, creating it if missing."""
|
|
obj, created = cls.objects.get_or_create(pk=1)
|
|
return obj
|