Spaces:
Sleeping
Sleeping
remove old state attributes
Browse files- planning_ai/states.py +5 -44
planning_ai/states.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import operator
|
2 |
from pathlib import Path
|
3 |
-
from typing import Annotated,
|
4 |
|
5 |
from langchain_core.documents import Document
|
6 |
from pydantic import BaseModel
|
@@ -10,60 +10,21 @@ from planning_ai.common.utils import filename_reducer
|
|
10 |
|
11 |
|
12 |
class DocumentState(TypedDict):
|
13 |
-
"""Represents the state of an individual document during processing.
|
14 |
-
|
15 |
-
This class is a TypedDict that encapsulates the state of a single document
|
16 |
-
during the processing workflow. It includes the document text, summary,
|
17 |
-
hallucination details, filename, and iteration count.
|
18 |
-
|
19 |
-
Attributes:
|
20 |
-
document (str): The text of the document.
|
21 |
-
summary (BriefSummary): The summary of the document.
|
22 |
-
hallucination (HallucinationChecker): The hallucination details for the document's summary.
|
23 |
-
filename (Path): The file path of the document.
|
24 |
-
iteration (int): The current iteration count for processing the document.
|
25 |
-
"""
|
26 |
-
|
27 |
document: Document
|
28 |
filename: Path
|
29 |
|
30 |
entities: list[dict]
|
31 |
themes: set[str]
|
32 |
summary: BaseModel
|
33 |
-
theme_docs: list[Document]
|
34 |
hallucination: HallucinationChecker
|
35 |
|
36 |
iteration: int
|
37 |
|
38 |
|
39 |
class OverallState(TypedDict):
|
40 |
-
|
41 |
-
|
42 |
-
This class is a TypedDict that encapsulates the overall state of the document
|
43 |
-
processing workflow. It includes information about the documents, summaries,
|
44 |
-
hallucinations, filenames, and iterations.
|
45 |
-
|
46 |
-
Attributes:
|
47 |
-
documents (list[str]): A list of document texts.
|
48 |
-
final_summary (str): The final aggregated summary of all documents.
|
49 |
-
summaries (Annotated[list, operator.add]): A list of initial summaries for each document.
|
50 |
-
summaries_fixed (Annotated[list, operator.add]): A list of summaries after fixing hallucinations.
|
51 |
-
hallucinations (Annotated[list, operator.add]): A list of detected hallucinations in summaries.
|
52 |
-
filenames (List[Path]): A list of file paths corresponding to the documents.
|
53 |
-
iterations (list[int]): A list of iteration counts for processing each document.
|
54 |
-
"""
|
55 |
-
|
56 |
documents: Annotated[list[DocumentState], filename_reducer]
|
57 |
-
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
# documents_related: Annotated[list, operator.add]
|
62 |
-
# related_theme_docs: Annotated[list, operator.add]
|
63 |
-
#
|
64 |
-
# summaries: Annotated[list, operator.add]
|
65 |
-
# summaries_fixed: Annotated[list, operator.add]
|
66 |
-
# hallucinations: Annotated[list, operator.add]
|
67 |
-
#
|
68 |
-
# filenames: Annotated[list, operator.add]
|
69 |
-
# iterations: list[int]
|
|
|
1 |
import operator
|
2 |
from pathlib import Path
|
3 |
+
from typing import Annotated, TypedDict
|
4 |
|
5 |
from langchain_core.documents import Document
|
6 |
from pydantic import BaseModel
|
|
|
10 |
|
11 |
|
12 |
class DocumentState(TypedDict):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
document: Document
|
14 |
filename: Path
|
15 |
|
16 |
entities: list[dict]
|
17 |
themes: set[str]
|
18 |
summary: BaseModel
|
|
|
19 |
hallucination: HallucinationChecker
|
20 |
|
21 |
iteration: int
|
22 |
|
23 |
|
24 |
class OverallState(TypedDict):
|
25 |
+
executive: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
documents: Annotated[list[DocumentState], filename_reducer]
|
27 |
+
policies_support: str
|
28 |
+
policies_object: str
|
29 |
|
30 |
+
n_docs: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|