diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index d025459e..eb914ed8 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -622,6 +622,8 @@ class AgentAdapters: @staticmethod def get_all_accessible_agents(user: KhojUser = None): public_query = Q(privacy_level=Agent.PrivacyLevel.PUBLIC) + # TODO Update this to allow any public agent that's officially approved once that experience is launched + public_query &= Q(managed_by_admin=True) if user: return ( Agent.objects.filter(public_query | Q(creator=user)) diff --git a/src/khoj/database/migrations/0070_alter_agent_input_tools_alter_agent_output_modes.py b/src/khoj/database/migrations/0070_alter_agent_input_tools_alter_agent_output_modes.py new file mode 100644 index 00000000..74dfc229 --- /dev/null +++ b/src/khoj/database/migrations/0070_alter_agent_input_tools_alter_agent_output_modes.py @@ -0,0 +1,46 @@ +# Generated by Django 5.0.8 on 2024-10-21 05:16 + +import django.contrib.postgres.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("database", "0069_webscraper_serverchatsettings_web_scraper"), + ] + + operations = [ + migrations.AlterField( + model_name="agent", + name="input_tools", + field=django.contrib.postgres.fields.ArrayField( + base_field=models.CharField( + choices=[ + ("general", "General"), + ("online", "Online"), + ("notes", "Notes"), + ("summarize", "Summarize"), + ("webpage", "Webpage"), + ], + max_length=200, + ), + blank=True, + default=list, + null=True, + size=None, + ), + ), + migrations.AlterField( + model_name="agent", + name="output_modes", + field=django.contrib.postgres.fields.ArrayField( + base_field=models.CharField( + choices=[("text", "Text"), ("image", "Image"), ("automation", "Automation")], max_length=200 + ), + blank=True, + default=list, + null=True, + size=None, + ), + ), + ] diff --git a/src/khoj/database/models/__init__.py b/src/khoj/database/models/__init__.py index 2b2fde2d..6b122dac 100644 --- a/src/khoj/database/models/__init__.py +++ b/src/khoj/database/models/__init__.py @@ -180,8 +180,12 @@ class Agent(BaseModel): ) # Creator will only be null when the agents are managed by admin name = models.CharField(max_length=200) personality = models.TextField() - input_tools = ArrayField(models.CharField(max_length=200, choices=InputToolOptions.choices), default=list) - output_modes = ArrayField(models.CharField(max_length=200, choices=OutputModeOptions.choices), default=list) + input_tools = ArrayField( + models.CharField(max_length=200, choices=InputToolOptions.choices), default=list, null=True, blank=True + ) + output_modes = ArrayField( + models.CharField(max_length=200, choices=OutputModeOptions.choices), default=list, null=True, blank=True + ) managed_by_admin = models.BooleanField(default=False) chat_model = models.ForeignKey(ChatModelOptions, on_delete=models.CASCADE) slug = models.CharField(max_length=200, unique=True)