Enhance FlowComponentInfo with timestamp and utility function
This commit updates the FlowComponentInfo class to include a validated_at field that stores the current timestamp in ISO format. A new utility function, get_datetime_now, is introduced to retrieve the current UTC time. Additionally, the ingestion validation logic is refined to include a check for OpenAI embeddings, improving the overall validation process.
This commit is contained in:
parent
40e625cf96
commit
e3d3ae95f0
1 changed files with 10 additions and 5 deletions
|
|
@ -3,8 +3,10 @@
|
|||
import asyncio
|
||||
from contextlib import contextmanager
|
||||
from contextvars import ContextVar
|
||||
from typing import Dict, List, Optional, Any
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from utils.logging_config import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
@ -33,12 +35,16 @@ class ComponentInfo:
|
|||
parameters: Dict[str, ComponentParameter] = field(default_factory=dict)
|
||||
|
||||
|
||||
def get_datetime_now() -> str:
|
||||
return datetime.now(timezone.utc).isoformat()
|
||||
|
||||
|
||||
@dataclass
|
||||
class FlowComponentInfo:
|
||||
"""Information about all components available in a flow."""
|
||||
|
||||
components: Dict[str, List[ComponentInfo]] = field(default_factory=dict)
|
||||
validated_at: Optional[float] = None
|
||||
validated_at: Optional[str] = field(default_factory=get_datetime_now)
|
||||
flow_id: Optional[str] = None
|
||||
|
||||
@property
|
||||
|
|
@ -60,10 +66,9 @@ class FlowComponentInfo:
|
|||
@property
|
||||
def is_valid_for_ingestion(self) -> bool:
|
||||
"""Check if flow has minimum required components for ingestion."""
|
||||
|
||||
return (
|
||||
self.has_file
|
||||
and self.has_opensearch_hybrid
|
||||
and len(self.components.get("File", [])) == 1
|
||||
self.has_file and self.has_opensearch_hybrid and self.has_openai_embeddings
|
||||
)
|
||||
|
||||
def get_available_parameters(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue