Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat(api): add input and output type to enricher template

dextmorgn2ea40c4eae53
diff --git a/flowsint-api/app/api/routes/enricher_templates.py b/flowsint-api/app/api/routes/enricher_templates.py
index 07b428c8..d4e5d9f7 100644
--- a/flowsint-api/app/api/routes/enricher_templates.py
+++ b/flowsint-api/app/api/routes/enricher_templates.py
@@ -18,6 +18,8 @@ from flowsint_core.core.vault import Vault
from flowsint_core.templates.types import Template
from sqlalchemy.orm import Session
+from flowsint_types.registry import get_type as get_type_from_registry, load_all_types
+
from app.api.deps import get_current_user
from app.api.schemas.enricher_template import (
EnricherTemplateCreate,
@@ -84,9 +86,39 @@ async def generate_template(
current_user: Profile = Depends(get_current_user),
):
"""Generate an enricher template from a free-text description using AI."""
+ load_all_types()
+
+ input_schema = None
+ output_schema = None
+
+ if request.input_type:
+ input_cls = get_type_from_registry(request.input_type, case_sensitive=True)
+ if input_cls is None:
+ raise HTTPException(
+ status_code=422,
+ detail=f"Unknown input type: '{request.input_type}'",
+ )
+ input_schema = input_cls.model_json_schema()
+
+ if request.output_type:
+ output_cls = get_type_from_registry(request.output_type, case_sensitive=True)
+ if output_cls is None:
+ raise HTTPException(
+ status_code=422,
+ detail=f"Unknown output type: '{request.output_type}'",
+ )
+ output_schema = output_cls.model_json_schema()
+
service = create_template_generator_service(db)
try:
- yaml_content = await service.generate(request.prompt, current_user.id)
+ yaml_content = await service.generate(
+ prompt=request.prompt,
+ owner_id=current_user.id,
+ input_type=request.input_type,
+ input_schema=input_schema,
+ output_type=request.output_type,
+ output_schema=output_schema,
+ )
except ValidationError as e:
raise HTTPException(status_code=422, detail=str(e))
return EnricherTemplateGenerateResponse(yaml_content=yaml_content)
diff --git a/flowsint-api/app/api/schemas/enricher_template.py b/flowsint-api/app/api/schemas/enricher_template.py
index 1e623fbd..9a75f7d1 100644
--- a/flowsint-api/app/api/schemas/enricher_template.py
+++ b/flowsint-api/app/api/schemas/enricher_template.py
@@ -174,6 +174,12 @@ class EnricherTemplateGenerateRequest(BaseModel):
max_length=16000,
description="Free-text description of the desired enricher template",
)
+ input_type: Optional[str] = Field(
+ None, description="Flowsint input type name (e.g. 'Ip', 'Domain')"
+ )
+ output_type: Optional[str] = Field(
+ None, description="Flowsint output type name (e.g. 'Ip', 'SocialAccount')"
+ )
class EnricherTemplateGenerateResponse(BaseModel):