diff --git a/core/map_projects/migrations/0033_mapproject_prompt_template_url_and_more.py b/core/map_projects/migrations/0033_mapproject_prompt_template_url_and_more.py new file mode 100644 index 00000000..20f6d0e3 --- /dev/null +++ b/core/map_projects/migrations/0033_mapproject_prompt_template_url_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.15 on 2026-05-07 04:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('map_projects', '0032_alter_mapproject_encoder_model'), + ] + + operations = [ + migrations.AddField( + model_name='mapproject', + name='prompt_template_url', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='mapproject', + name='encoder_model', + field=models.TextField(blank=True, default='BAAI/bge-reranker-v2-m3', null=True), + ), + ] diff --git a/core/map_projects/migrations/0034_rename_prompt_template_url_mapproject_prompt_template_key.py b/core/map_projects/migrations/0034_rename_prompt_template_url_mapproject_prompt_template_key.py new file mode 100644 index 00000000..d1e1016f --- /dev/null +++ b/core/map_projects/migrations/0034_rename_prompt_template_url_mapproject_prompt_template_key.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.15 on 2026-05-07 12:21 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('map_projects', '0033_mapproject_prompt_template_url_and_more'), + ] + + operations = [ + migrations.RenameField( + model_name='mapproject', + old_name='prompt_template_url', + new_name='prompt_template_key', + ), + ] diff --git a/core/map_projects/models.py b/core/map_projects/models.py index 7e64d1e8..adfa9074 100644 --- a/core/map_projects/models.py +++ b/core/map_projects/models.py @@ -40,13 +40,14 @@ class MapProject(BaseModel): lookup_config = models.JSONField(default=dict, null=True, blank=True) analysis = models.JSONField(default=dict, null=True, blank=True) encoder_model = models.TextField(null=True, blank=True, default=settings.ENCODER_MODEL_NAME) + prompt_template_key = models.TextField(null=True, blank=True) # Fields that define how a project matches — # excluding identity, results, logs, and audit metadata. # Used by the copy-project flow. CONFIGURATION_FIELDS = [ 'algorithms', 'encoder_model', 'filters', 'include_retired', - 'lookup_config', 'score_configuration', 'target_repo_url', + 'lookup_config', 'score_configuration', 'target_repo_url', 'prompt_template_key' ] class Meta: diff --git a/core/map_projects/serializers.py b/core/map_projects/serializers.py index 56b2973c..201f03d8 100644 --- a/core/map_projects/serializers.py +++ b/core/map_projects/serializers.py @@ -22,7 +22,8 @@ class Meta: 'created_by', 'updated_by', 'created_at', 'updated_at', 'url', 'is_active', 'public_access', 'file', 'user_id', 'organization_id', 'description', 'target_repo_url', 'include_retired', 'score_configuration', - 'filters', 'candidates', 'algorithms', 'lookup_config', 'analysis', 'encoder_model' + 'filters', 'candidates', 'algorithms', 'lookup_config', 'analysis', 'encoder_model', + 'prompt_template_key' ] def prepare_object(self, validated_data, instance=None, file=None): @@ -37,7 +38,7 @@ def prepare_object(self, validated_data, instance=None, file=None): for attr in [ 'name', 'description', 'extras', 'target_repo_url', 'include_retired', 'score_configuration', 'filters', 'candidates', 'algorithms', 'lookup_config', 'analysis', - 'encoder_model' + 'encoder_model', 'prompt_template_key' ]: setattr(instance, attr, validated_data.get(attr, get(instance, attr))) if not instance.id: diff --git a/core/map_projects/tests/tests.py b/core/map_projects/tests/tests.py index 43d33179..05e84114 100644 --- a/core/map_projects/tests/tests.py +++ b/core/map_projects/tests/tests.py @@ -134,6 +134,7 @@ def test_get_200(self): lookup_config={'concepts': {'limit': 20}}, score_configuration={'recommended': 95, 'available': 75}, target_repo_url='/orgs/CIEL/sources/CIEL/', + prompt_template_key='match-recommend' ) project.save() @@ -154,5 +155,6 @@ def test_get_200(self): self.assertEqual(response.data['lookup_config'], {'concepts': {'limit': 20}}) self.assertEqual(response.data['score_configuration'], {'recommended': 95, 'available': 75}) self.assertEqual(response.data['target_repo_url'], '/orgs/CIEL/sources/CIEL/') + self.assertEqual(response.data['prompt_template_key'], 'match-recommend') for field in ['analysis', 'input_file_name', 'candidates', 'matches', 'columns', 'created_by', 'updated_by']: self.assertNotIn(field, response.data)