Skip to content

Commit

Permalink
make ai_settings_extractions not required muchdogesec/obstracts#33
Browse files Browse the repository at this point in the history
  • Loading branch information
fqrious committed Nov 12, 2024
1 parent c3e1860 commit c374a21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dogesec_commons/stixifier/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ProfileSerializer(serializers.ModelSerializer):
ai_settings_extractions = serializers.ListField(
child=serializers.CharField(max_length=256, validators=[validate_model]),
help_text='(required if AI extractions enabled) passed in format provider[:model] e.g. openai:gpt4o. Can pass more than one value to get extractions from multiple providers. model part is optional',
required=False,
)
extractions = serializers.ListField(
min_length=1,
Expand All @@ -86,9 +87,9 @@ class Meta:
fields = "__all__"

def validate(self, attrs):
if attrs['relationship_mode'] == 'ai' and not attrs['ai_settings_relationships']:
if attrs['relationship_mode'] == 'ai' and not attrs.get('ai_settings_relationships'):
raise ValidationError('AI `relationship_mode` requires a valid `ai_settings_relationships`')
if not attrs['ai_settings_extractions']:
if not attrs.get('ai_settings_extractions'):
uses_ai(attrs['extractions'])
return super().validate(attrs)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "dogesec_commons"
version = "0.0.1b1"
version = "0.0.1b2"
authors = [
{ name="DOGESEC", email="[email protected]" },
]
Expand Down

0 comments on commit c374a21

Please sign in to comment.