Spaces:
Paused

File size: 1,787 Bytes
5eb4857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b7980f7
 
 
 
5eb4857
 
 
 
 
 
 
 
 
 
 
 
 
b7980f7
5eb4857
b7980f7
 
5eb4857
 
b7980f7
5eb4857
b7980f7
5eb4857
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from typing import TypedDict, List, Optional, Any, Dict, Annotated
from uuid import UUID

def merge_list(current: List[Any], new: List[Any]) -> List[Any]:
    return (current or []) + (new or [])

def merge_dict(current: Dict[str, Any], new: Dict[str, Any]) -> Dict[str, Any]:
    _c = current.copy() if current else {}
    if new:
        _c.update(new)
    return _c

class AgentState(TypedDict):
    """
    Shared state for the Customer Portal Agentic Workflow.
    """
    # Source Info
    ticket_id: UUID
    workspace_id: UUID
    thread_id: Optional[UUID]
    title: str
    description: str
    attachments: Optional[List[Any]] # Serialized attachment data (id, filename, ai_caption)
    
    # --- Consolidated AI Ingestion ---
    embedding: Optional[List[float]] # Shared Centroid Vector (Nomic-768)
    vision_context: Optional[List[Dict[str, Any]]] # Image Captions/Refs
    
    # Processed Results
    category: Optional[str]
    priority: Optional[str]
    sentiment: Optional[str]
    
    # Duplication Info
    is_duplicate: bool
    duplicate_of_id: Optional[UUID]
    
    # Generated Outputs
    assigned_to: Optional[UUID]
    status: Optional[str]
    suggested_reply: Optional[str]
    kb_suggested_solution: Optional[str]
    internal_summary: Optional[str]
    kb_extracts: Optional[List[Dict[str, Any]]] # Relevant KB articles or chunks
    is_new_topic: bool = False # Flag for KB expansion
    
    # Flow Control
    target_team: Optional[str] # Identified department (Engineering, SecOps, etc.)
    next_node: Optional[str]
    proposed_insights: Annotated[List[Dict[str, Any]], merge_list]
    errors: Annotated[List[str], merge_list]
    metadata: Annotated[Dict[str, Any], merge_dict]
    processed_steps: Annotated[List[Dict[str, Any]], merge_list]