mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 18:47:11 +00:00
Use recognizable DB model names to ease selection UX on Admin Panel
Previously id were used (by default) for model display strings. This made it hard to select chat model options, server chat settings etc. in the admin panel dropdowns. This change uses more recognizable names for the DB objects to ease selection in dropdowns and display in general on the admin panel.
This commit is contained in:
parent
d10dc9cfe1
commit
b660c494bc
2 changed files with 27 additions and 3 deletions
|
@ -217,10 +217,10 @@ class ChatModelOptionsAdmin(unfold_admin.ModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
"id",
|
"id",
|
||||||
"chat_model",
|
"chat_model",
|
||||||
"model_type",
|
"ai_model_api",
|
||||||
"max_prompt_size",
|
"max_prompt_size",
|
||||||
)
|
)
|
||||||
search_fields = ("id", "chat_model", "model_type")
|
search_fields = ("id", "chat_model", "ai_model_api__name")
|
||||||
|
|
||||||
|
|
||||||
@admin.register(TextToImageModelConfig)
|
@admin.register(TextToImageModelConfig)
|
||||||
|
@ -288,7 +288,7 @@ class ConversationAdmin(unfold_admin.ModelAdmin):
|
||||||
"client",
|
"client",
|
||||||
)
|
)
|
||||||
search_fields = ("id", "user__email", "user__username", "client__name")
|
search_fields = ("id", "user__email", "user__username", "client__name")
|
||||||
list_filter = ("agent",)
|
list_filter = ("agent", "client", "user")
|
||||||
ordering = ("-created_at",)
|
ordering = ("-created_at",)
|
||||||
|
|
||||||
actions = ["export_selected_objects", "export_selected_minimal_objects"]
|
actions = ["export_selected_objects", "export_selected_minimal_objects"]
|
||||||
|
|
|
@ -144,6 +144,9 @@ class KhojUser(AbstractUser):
|
||||||
self.uuid = uuid.uuid4()
|
self.uuid = uuid.uuid4()
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.username} ({self.uuid})"
|
||||||
|
|
||||||
|
|
||||||
class GoogleUser(models.Model):
|
class GoogleUser(models.Model):
|
||||||
user = models.OneToOneField(KhojUser, on_delete=models.CASCADE)
|
user = models.OneToOneField(KhojUser, on_delete=models.CASCADE)
|
||||||
|
@ -186,6 +189,9 @@ class AiModelApi(DbBaseModel):
|
||||||
api_key = models.CharField(max_length=200)
|
api_key = models.CharField(max_length=200)
|
||||||
api_base_url = models.URLField(max_length=200, default=None, blank=True, null=True)
|
api_base_url = models.URLField(max_length=200, default=None, blank=True, null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class ChatModelOptions(DbBaseModel):
|
class ChatModelOptions(DbBaseModel):
|
||||||
class ModelType(models.TextChoices):
|
class ModelType(models.TextChoices):
|
||||||
|
@ -202,6 +208,9 @@ class ChatModelOptions(DbBaseModel):
|
||||||
vision_enabled = models.BooleanField(default=False)
|
vision_enabled = models.BooleanField(default=False)
|
||||||
ai_model_api = models.ForeignKey(AiModelApi, on_delete=models.CASCADE, default=None, null=True, blank=True)
|
ai_model_api = models.ForeignKey(AiModelApi, on_delete=models.CASCADE, default=None, null=True, blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.chat_model
|
||||||
|
|
||||||
|
|
||||||
class VoiceModelOption(DbBaseModel):
|
class VoiceModelOption(DbBaseModel):
|
||||||
model_id = models.CharField(max_length=200)
|
model_id = models.CharField(max_length=200)
|
||||||
|
@ -307,6 +316,9 @@ class Agent(DbBaseModel):
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class ProcessLock(DbBaseModel):
|
class ProcessLock(DbBaseModel):
|
||||||
class Operation(models.TextChoices):
|
class Operation(models.TextChoices):
|
||||||
|
@ -420,6 +432,9 @@ class WebScraper(DbBaseModel):
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class ServerChatSettings(DbBaseModel):
|
class ServerChatSettings(DbBaseModel):
|
||||||
chat_default = models.ForeignKey(
|
chat_default = models.ForeignKey(
|
||||||
|
@ -492,6 +507,9 @@ class SearchModelConfig(DbBaseModel):
|
||||||
# The confidence threshold of the bi_encoder model to consider the embeddings as relevant
|
# The confidence threshold of the bi_encoder model to consider the embeddings as relevant
|
||||||
bi_encoder_confidence_threshold = models.FloatField(default=0.18)
|
bi_encoder_confidence_threshold = models.FloatField(default=0.18)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class TextToImageModelConfig(DbBaseModel):
|
class TextToImageModelConfig(DbBaseModel):
|
||||||
class ModelType(models.TextChoices):
|
class ModelType(models.TextChoices):
|
||||||
|
@ -527,6 +545,9 @@ class TextToImageModelConfig(DbBaseModel):
|
||||||
self.clean()
|
self.clean()
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.model_name} - {self.model_type}"
|
||||||
|
|
||||||
|
|
||||||
class SpeechToTextModelOptions(DbBaseModel):
|
class SpeechToTextModelOptions(DbBaseModel):
|
||||||
class ModelType(models.TextChoices):
|
class ModelType(models.TextChoices):
|
||||||
|
@ -536,6 +557,9 @@ class SpeechToTextModelOptions(DbBaseModel):
|
||||||
model_name = models.CharField(max_length=200, default="base")
|
model_name = models.CharField(max_length=200, default="base")
|
||||||
model_type = models.CharField(max_length=200, choices=ModelType.choices, default=ModelType.OFFLINE)
|
model_type = models.CharField(max_length=200, choices=ModelType.choices, default=ModelType.OFFLINE)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.model_name} - {self.model_type}"
|
||||||
|
|
||||||
|
|
||||||
class UserConversationConfig(DbBaseModel):
|
class UserConversationConfig(DbBaseModel):
|
||||||
user = models.OneToOneField(KhojUser, on_delete=models.CASCADE)
|
user = models.OneToOneField(KhojUser, on_delete=models.CASCADE)
|
||||||
|
|
Loading…
Reference in a new issue