File size: 1,304 Bytes
7042c3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""State management for the index graph."""

from dataclasses import dataclass
from typing import Annotated, Optional

from langchain_core.documents import Document

from ea4all.src.shared.state import reduce_docs

@dataclass(kw_only=True)
class InputState:
    """Represents the input state for the index graph.

    This class is used to pass the input documents to the index graph.
    It contains a single field, `path`, which is the source of documents.
    """

    path: Optional[str] = None
    """Document source path to be indexed by the graph."""


# The index state defines the simple IO for the single-node index graph
@dataclass(kw_only=True)
class OutputState:
    """Represents the state for document indexing and retrieval.

    This class defines the structure of the index state, which includes
    the documents to be indexed and the retriever used for searching
    these documents.
    """

    docs: Annotated[list[Document], reduce_docs]
    """A list of documents that the agent can index."""

@dataclass(kw_only=True)
class OverallState(InputState):
    """Represents the overall state of the index graph.

    This class combines the input and output states, allowing for
    both input documents and indexed documents to be managed within
    the same state.
    """

    pass