cs-models 0.0.827__py3-none-any.whl → 0.0.847__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cs_models/resources/CompanyOUS/models.py +2 -0
- cs_models/resources/CompanyOUS/schemas.py +4 -0
- cs_models/resources/CompanySEC/models.py +2 -0
- cs_models/resources/CompanySEC/schemas.py +4 -0
- cs_models/resources/DeepResearchAgenticUnit/__init__.py +14 -0
- cs_models/resources/DeepResearchAgenticUnit/models.py +123 -0
- cs_models/resources/DeepResearchAgenticUnit/schemas.py +50 -0
- cs_models/resources/DeepResearchSession/__init__.py +20 -0
- cs_models/resources/DeepResearchSession/models.py +170 -0
- cs_models/resources/DeepResearchSession/schemas.py +94 -0
- cs_models/resources/DeepResearchSubTask/__init__.py +20 -0
- cs_models/resources/DeepResearchSubTask/models.py +177 -0
- cs_models/resources/DeepResearchSubTask/schemas.py +105 -0
- cs_models/resources/MeetingUserDocument/__init__.py +0 -0
- cs_models/resources/MeetingUserDocument/models.py +39 -0
- cs_models/resources/MeetingUserDocument/schemas.py +17 -0
- cs_models/resources/PipelineCrawlSession/__init__.py +0 -0
- cs_models/resources/PipelineCrawlSession/models.py +67 -0
- cs_models/resources/PipelineCrawlSession/schemas.py +22 -0
- cs_models/resources/PipelineCrawledPage/__init__.py +0 -0
- cs_models/resources/PipelineCrawledPage/models.py +80 -0
- cs_models/resources/PipelineCrawledPage/schemas.py +34 -0
- cs_models/resources/PipelineDrugPortfolio/__init__.py +0 -0
- cs_models/resources/PipelineDrugPortfolio/models.py +92 -0
- cs_models/resources/PipelineDrugPortfolio/schemas.py +31 -0
- cs_models/resources/PipelineExtractionLog/__init__.py +0 -0
- cs_models/resources/PipelineExtractionLog/models.py +55 -0
- cs_models/resources/PipelineExtractionLog/schemas.py +23 -0
- cs_models/resources/PubmedMeetingSellSideSignal/__init__.py +0 -0
- cs_models/resources/PubmedMeetingSellSideSignal/models.py +64 -0
- cs_models/resources/PubmedMeetingSellSideSignal/schemas.py +21 -0
- cs_models/resources/PubmedMeetingUserDocument/__init__.py +0 -0
- cs_models/resources/PubmedMeetingUserDocument/models.py +40 -0
- cs_models/resources/PubmedMeetingUserDocument/schemas.py +16 -0
- cs_models/resources/SellSideAbstractMention/__init__.py +0 -0
- cs_models/resources/SellSideAbstractMention/models.py +57 -0
- cs_models/resources/SellSideAbstractMention/schemas.py +28 -0
- cs_models/resources/SellSideAbstractMentionLink/__init__.py +0 -0
- cs_models/resources/SellSideAbstractMentionLink/models.py +60 -0
- cs_models/resources/SellSideAbstractMentionLink/schemas.py +24 -0
- cs_models/resources/SellSideSource/__init__.py +0 -0
- cs_models/resources/SellSideSource/models.py +25 -0
- cs_models/resources/SellSideSource/schemas.py +13 -0
- cs_models/resources/UserDocument/models.py +7 -0
- cs_models/resources/UserDocument/schemas.py +2 -0
- cs_models/resources/UserDocumentAccess/models.py +6 -0
- cs_models/resources/UserDocumentAccess/schemas.py +1 -0
- cs_models/resources/Workbook/models.py +9 -0
- cs_models/resources/Workbook/schemas.py +6 -0
- cs_models/resources/WorkbookCommentThread/__init__.py +0 -0
- cs_models/resources/WorkbookCommentThread/models.py +59 -0
- cs_models/resources/WorkbookCommentThread/schemas.py +35 -0
- cs_models/resources/WorkbookThreadComment/__init__.py +0 -0
- cs_models/resources/WorkbookThreadComment/models.py +38 -0
- cs_models/resources/WorkbookThreadComment/schemas.py +14 -0
- {cs_models-0.0.827.dist-info → cs_models-0.0.847.dist-info}/METADATA +1 -1
- {cs_models-0.0.827.dist-info → cs_models-0.0.847.dist-info}/RECORD +59 -14
- {cs_models-0.0.827.dist-info → cs_models-0.0.847.dist-info}/WHEEL +0 -0
- {cs_models-0.0.827.dist-info → cs_models-0.0.847.dist-info}/top_level.txt +0 -0
|
@@ -28,6 +28,8 @@ class CompanyOUSModel(Base):
|
|
|
28
28
|
is_activated = Column(Boolean, nullable=True)
|
|
29
29
|
is_searchable = Column(Boolean, nullable=True)
|
|
30
30
|
last_crawl_date = Column(DateTime, nullable=True)
|
|
31
|
+
last_pipeline_crawl_date = Column(DateTime, nullable=True)
|
|
32
|
+
pipeline_crawl_enabled = Column(Boolean, nullable=True, default=True)
|
|
31
33
|
industry_type = Column(String(50), nullable=True)
|
|
32
34
|
company_sec_link = Column(
|
|
33
35
|
Integer,
|
|
@@ -20,6 +20,8 @@ class CompanyOUSResourceSchema(Schema):
|
|
|
20
20
|
is_activated = fields.Boolean(allow_none=True)
|
|
21
21
|
is_searchable = fields.Boolean(allow_none=True)
|
|
22
22
|
last_crawl_date = fields.DateTime(allow_none=True)
|
|
23
|
+
last_pipeline_crawl_date = fields.DateTime(allow_none=True)
|
|
24
|
+
pipeline_crawl_enabled = fields.Boolean(allow_none=True)
|
|
23
25
|
industry_type = fields.String(allow_none=True)
|
|
24
26
|
company_sec_link = fields.Integer(allow_none=True)
|
|
25
27
|
relevant_links = fields.String(allow_none=True)
|
|
@@ -43,6 +45,8 @@ class CompanyOUSUpdateSchema(Schema):
|
|
|
43
45
|
pipeline_url = fields.String(allow_none=True)
|
|
44
46
|
ir_url = fields.String(allow_none=True)
|
|
45
47
|
last_crawl_date = fields.DateTime(allow_none=True)
|
|
48
|
+
last_pipeline_crawl_date = fields.DateTime(allow_none=True)
|
|
49
|
+
pipeline_crawl_enabled = fields.Boolean(allow_none=True)
|
|
46
50
|
industry_type = fields.String(allow_none=True)
|
|
47
51
|
company_sec_link = fields.Integer(allow_none=True)
|
|
48
52
|
updated_at = fields.DateTime(dump_only=True)
|
|
@@ -32,6 +32,8 @@ class CompanySECModel(Base):
|
|
|
32
32
|
discarded = Column(Boolean, nullable=True)
|
|
33
33
|
skip_sec = Column(Boolean, nullable=True)
|
|
34
34
|
last_crawl_date = Column(DateTime, nullable=True)
|
|
35
|
+
last_pipeline_crawl_date = Column(DateTime, nullable=True)
|
|
36
|
+
pipeline_crawl_enabled = Column(Boolean, nullable=True, default=True)
|
|
35
37
|
industry_type = Column(String(50), nullable=True)
|
|
36
38
|
relevant_links = Column(Text, nullable=True)
|
|
37
39
|
notes = Column(Text, nullable=True)
|
|
@@ -24,6 +24,8 @@ class CompanySECResourceSchema(Schema):
|
|
|
24
24
|
discarded = fields.Boolean(allow_none=True)
|
|
25
25
|
skip_sec = fields.Boolean(allow_none=True)
|
|
26
26
|
last_crawl_date = fields.DateTime(allow_none=True)
|
|
27
|
+
last_pipeline_crawl_date = fields.DateTime(allow_none=True)
|
|
28
|
+
pipeline_crawl_enabled = fields.Boolean(allow_none=True)
|
|
27
29
|
industry_type = fields.String(allow_none=True)
|
|
28
30
|
relevant_links = fields.String(allow_none=True)
|
|
29
31
|
notes = fields.String(allow_none=True)
|
|
@@ -43,5 +45,7 @@ class CompanySECUpdateSchema(Schema):
|
|
|
43
45
|
discarded = fields.Boolean(allow_none=True)
|
|
44
46
|
skip_sec = fields.Boolean(allow_none=True)
|
|
45
47
|
last_crawl_date = fields.DateTime(allow_none=True)
|
|
48
|
+
last_pipeline_crawl_date = fields.DateTime(allow_none=True)
|
|
49
|
+
pipeline_crawl_enabled = fields.Boolean(allow_none=True)
|
|
46
50
|
industry_type = fields.String(allow_none=True)
|
|
47
51
|
updated_at = fields.DateTime(dump_only=True)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""DeepResearchAgenticUnit - Self-contained research modules for v2 architecture."""
|
|
2
|
+
|
|
3
|
+
from .models import DeepResearchAgenticUnitModel, UnitStatusEnum
|
|
4
|
+
from .schemas import (
|
|
5
|
+
DeepResearchAgenticUnitResourceSchema,
|
|
6
|
+
DeepResearchAgenticUnitCreateSchema,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"DeepResearchAgenticUnitModel",
|
|
11
|
+
"UnitStatusEnum",
|
|
12
|
+
"DeepResearchAgenticUnitResourceSchema",
|
|
13
|
+
"DeepResearchAgenticUnitCreateSchema",
|
|
14
|
+
]
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Models for Deep Research Agentic Units - Self-contained research modules."""
|
|
2
|
+
import enum
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from sqlalchemy import (
|
|
6
|
+
Column,
|
|
7
|
+
DateTime,
|
|
8
|
+
Integer,
|
|
9
|
+
String,
|
|
10
|
+
Text,
|
|
11
|
+
Boolean,
|
|
12
|
+
ForeignKey,
|
|
13
|
+
Enum,
|
|
14
|
+
Float,
|
|
15
|
+
)
|
|
16
|
+
from sqlalchemy.orm import relationship
|
|
17
|
+
|
|
18
|
+
from ...database import Base
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class UnitStatusEnum(enum.Enum):
|
|
22
|
+
"""Status enum for agentic units."""
|
|
23
|
+
PENDING = "PENDING"
|
|
24
|
+
PLANNING = "PLANNING" # Internal DAG being planned
|
|
25
|
+
EXECUTING = "EXECUTING" # Internal tasks running
|
|
26
|
+
COMPLETED = "COMPLETED"
|
|
27
|
+
FAILED = "FAILED"
|
|
28
|
+
SKIPPED = "SKIPPED"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class DeepResearchAgenticUnitModel(Base):
|
|
32
|
+
"""
|
|
33
|
+
Model for Deep Research Agentic Units.
|
|
34
|
+
|
|
35
|
+
An Agentic Unit is a self-contained research module that answers
|
|
36
|
+
ONE coherent objective using any combination of internal tasks
|
|
37
|
+
(DISCOVERY, INVESTIGATION, SMART_GRID, AGGREGATION).
|
|
38
|
+
|
|
39
|
+
Part of the V2 architecture that replaces rigid upfront DAG decomposition
|
|
40
|
+
with an adaptive Plan -> Execute -> Evaluate loop.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
__tablename__ = "deep_research_agentic_units"
|
|
44
|
+
|
|
45
|
+
id = Column(Integer, primary_key=True)
|
|
46
|
+
|
|
47
|
+
# Parent session
|
|
48
|
+
session_id = Column(
|
|
49
|
+
Integer,
|
|
50
|
+
ForeignKey("deep_research_sessions.id"),
|
|
51
|
+
nullable=False,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Identity
|
|
55
|
+
unit_id = Column(String(50), nullable=False) # Logical ID: "A", "B", "C", etc.
|
|
56
|
+
unit_label = Column(String(255), nullable=True) # Human-readable label
|
|
57
|
+
objective = Column(Text, nullable=False) # What this unit answers
|
|
58
|
+
|
|
59
|
+
# DAG Structure (outer DAG - dependencies between units)
|
|
60
|
+
depends_on = Column(Text, nullable=True) # JSON: ["A", "B"] - other unit_ids
|
|
61
|
+
wave_number = Column(Integer, default=0) # Computed from dependencies
|
|
62
|
+
|
|
63
|
+
# Internal Structure (inner DAG - tasks within this unit)
|
|
64
|
+
internal_dag = Column(Text, nullable=True) # JSON: List of internal tasks
|
|
65
|
+
internal_dag_planned = Column(Boolean, default=False)
|
|
66
|
+
|
|
67
|
+
# Execution State
|
|
68
|
+
status = Column(
|
|
69
|
+
"status",
|
|
70
|
+
Enum(UnitStatusEnum),
|
|
71
|
+
default=UnitStatusEnum.PENDING,
|
|
72
|
+
nullable=False,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Outputs (populated after execution)
|
|
76
|
+
result_s3_key = Column(String(512), nullable=True)
|
|
77
|
+
result_summary = Column(Text, nullable=True) # Concise answer to objective
|
|
78
|
+
entities_discovered = Column(Text, nullable=True) # JSON: Entities found (if any)
|
|
79
|
+
confidence = Column(Float, nullable=True) # 0-1 confidence in results
|
|
80
|
+
gaps_identified = Column(Text, nullable=True) # JSON: What couldn't be answered
|
|
81
|
+
|
|
82
|
+
# Metrics
|
|
83
|
+
tokens_used = Column(Integer, default=0)
|
|
84
|
+
tasks_completed = Column(Integer, default=0)
|
|
85
|
+
tasks_failed = Column(Integer, default=0)
|
|
86
|
+
|
|
87
|
+
# Context from dependencies (populated before execution)
|
|
88
|
+
input_context = Column(Text, nullable=True) # JSON: Summaries from dependency units
|
|
89
|
+
|
|
90
|
+
# Timestamps
|
|
91
|
+
created_at = Column(
|
|
92
|
+
DateTime,
|
|
93
|
+
nullable=False,
|
|
94
|
+
default=lambda: datetime.utcnow(),
|
|
95
|
+
)
|
|
96
|
+
started_at = Column(DateTime, nullable=True)
|
|
97
|
+
completed_at = Column(DateTime, nullable=True)
|
|
98
|
+
updated_at = Column(
|
|
99
|
+
DateTime,
|
|
100
|
+
nullable=False,
|
|
101
|
+
default=lambda: datetime.utcnow(),
|
|
102
|
+
onupdate=lambda: datetime.utcnow(),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Error handling
|
|
106
|
+
error_message = Column(Text, nullable=True)
|
|
107
|
+
retry_count = Column(Integer, default=0)
|
|
108
|
+
|
|
109
|
+
# Soft delete
|
|
110
|
+
is_deleted = Column(Boolean, nullable=True)
|
|
111
|
+
|
|
112
|
+
# ORM Relationships
|
|
113
|
+
session = relationship(
|
|
114
|
+
"DeepResearchSessionModel",
|
|
115
|
+
back_populates="agentic_units",
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
internal_tasks = relationship(
|
|
119
|
+
"DeepResearchSubTaskModel",
|
|
120
|
+
primaryjoin="and_(DeepResearchAgenticUnitModel.id==DeepResearchSubTaskModel.agentic_unit_id, "
|
|
121
|
+
"or_(DeepResearchSubTaskModel.is_deleted==False, DeepResearchSubTaskModel.is_deleted==None))",
|
|
122
|
+
back_populates="agentic_unit",
|
|
123
|
+
)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Marshmallow schemas for Deep Research Agentic Units."""
|
|
2
|
+
|
|
3
|
+
from marshmallow import Schema, fields, EXCLUDE
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DeepResearchAgenticUnitResourceSchema(Schema):
|
|
7
|
+
"""Schema for reading agentic unit resources."""
|
|
8
|
+
|
|
9
|
+
class Meta:
|
|
10
|
+
unknown = EXCLUDE
|
|
11
|
+
|
|
12
|
+
id = fields.Integer(dump_only=True)
|
|
13
|
+
session_id = fields.Integer(required=True)
|
|
14
|
+
unit_id = fields.String(required=True)
|
|
15
|
+
unit_label = fields.String(allow_none=True)
|
|
16
|
+
objective = fields.String(required=True)
|
|
17
|
+
depends_on = fields.String(allow_none=True) # JSON string
|
|
18
|
+
wave_number = fields.Integer(allow_none=True)
|
|
19
|
+
internal_dag = fields.String(allow_none=True) # JSON string
|
|
20
|
+
internal_dag_planned = fields.Boolean(allow_none=True)
|
|
21
|
+
status = fields.String(allow_none=True)
|
|
22
|
+
result_s3_key = fields.String(allow_none=True)
|
|
23
|
+
result_summary = fields.String(allow_none=True)
|
|
24
|
+
entities_discovered = fields.String(allow_none=True) # JSON string
|
|
25
|
+
confidence = fields.Float(allow_none=True)
|
|
26
|
+
gaps_identified = fields.String(allow_none=True) # JSON string
|
|
27
|
+
tokens_used = fields.Integer(allow_none=True)
|
|
28
|
+
tasks_completed = fields.Integer(allow_none=True)
|
|
29
|
+
tasks_failed = fields.Integer(allow_none=True)
|
|
30
|
+
input_context = fields.String(allow_none=True) # JSON string
|
|
31
|
+
created_at = fields.DateTime(dump_only=True)
|
|
32
|
+
started_at = fields.DateTime(allow_none=True)
|
|
33
|
+
completed_at = fields.DateTime(allow_none=True)
|
|
34
|
+
updated_at = fields.DateTime(dump_only=True)
|
|
35
|
+
error_message = fields.String(allow_none=True)
|
|
36
|
+
retry_count = fields.Integer(allow_none=True)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class DeepResearchAgenticUnitCreateSchema(Schema):
|
|
40
|
+
"""Schema for creating agentic units."""
|
|
41
|
+
|
|
42
|
+
class Meta:
|
|
43
|
+
unknown = EXCLUDE
|
|
44
|
+
|
|
45
|
+
session_id = fields.Integer(required=True)
|
|
46
|
+
unit_id = fields.String(required=True)
|
|
47
|
+
unit_label = fields.String(allow_none=True)
|
|
48
|
+
objective = fields.String(required=True)
|
|
49
|
+
depends_on = fields.String(allow_none=True) # JSON string of unit_ids
|
|
50
|
+
wave_number = fields.Integer(allow_none=True, load_default=0)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Deep Research Session model and schema exports."""
|
|
2
|
+
from .models import (
|
|
3
|
+
DeepResearchSessionModel,
|
|
4
|
+
DeepResearchStatusEnum,
|
|
5
|
+
HITLStatusEnum,
|
|
6
|
+
)
|
|
7
|
+
from .schemas import (
|
|
8
|
+
DeepResearchSessionResourceSchema,
|
|
9
|
+
DeepResearchSessionCreateSchema,
|
|
10
|
+
DeepResearchSessionProgressSchema,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"DeepResearchSessionModel",
|
|
15
|
+
"DeepResearchStatusEnum",
|
|
16
|
+
"HITLStatusEnum",
|
|
17
|
+
"DeepResearchSessionResourceSchema",
|
|
18
|
+
"DeepResearchSessionCreateSchema",
|
|
19
|
+
"DeepResearchSessionProgressSchema",
|
|
20
|
+
]
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Models for Deep Research Sessions - Agentic research orchestration."""
|
|
2
|
+
import enum
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from sqlalchemy import (
|
|
6
|
+
Column,
|
|
7
|
+
DateTime,
|
|
8
|
+
Integer,
|
|
9
|
+
String,
|
|
10
|
+
Text,
|
|
11
|
+
Boolean,
|
|
12
|
+
ForeignKey,
|
|
13
|
+
Enum,
|
|
14
|
+
Float,
|
|
15
|
+
)
|
|
16
|
+
from sqlalchemy.orm import relationship
|
|
17
|
+
|
|
18
|
+
from ...database import Base
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class DeepResearchStatusEnum(enum.Enum):
|
|
22
|
+
"""Status enum for deep research sessions."""
|
|
23
|
+
NOT_STARTED = "NOT_STARTED"
|
|
24
|
+
DECOMPOSING = "DECOMPOSING"
|
|
25
|
+
WAITING_USER_CLARIFICATION = "WAITING_USER_CLARIFICATION"
|
|
26
|
+
WAITING_SCOPE_APPROVAL = "WAITING_SCOPE_APPROVAL"
|
|
27
|
+
RESEARCHING = "RESEARCHING"
|
|
28
|
+
SYNTHESIZING = "SYNTHESIZING"
|
|
29
|
+
WAITING_USER_REVIEW = "WAITING_USER_REVIEW"
|
|
30
|
+
DRILL_DOWN = "DRILL_DOWN"
|
|
31
|
+
COMPLETED = "COMPLETED"
|
|
32
|
+
FAILED = "FAILED"
|
|
33
|
+
CANCELLED = "CANCELLED"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class HITLStatusEnum(enum.Enum):
|
|
37
|
+
"""Human-in-the-loop status enum."""
|
|
38
|
+
NONE = "NONE"
|
|
39
|
+
PENDING = "PENDING"
|
|
40
|
+
RESPONDED = "RESPONDED"
|
|
41
|
+
TIMEOUT = "TIMEOUT"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class DeepResearchSessionModel(Base):
|
|
45
|
+
"""
|
|
46
|
+
Model for Deep Research Sessions.
|
|
47
|
+
|
|
48
|
+
Each session represents a complex research task that is decomposed into
|
|
49
|
+
parallel sub-tasks executed by independent agents. Supports human-in-the-loop
|
|
50
|
+
checkpoints for clarification, scope approval, and result review.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
__tablename__ = "deep_research_sessions"
|
|
54
|
+
|
|
55
|
+
id = Column(Integer, primary_key=True)
|
|
56
|
+
|
|
57
|
+
# User and organization
|
|
58
|
+
user_id = Column(String(128), nullable=False)
|
|
59
|
+
org_id = Column(String(128), nullable=True)
|
|
60
|
+
|
|
61
|
+
# Link to workbook (optional)
|
|
62
|
+
workbook_id = Column(
|
|
63
|
+
Integer,
|
|
64
|
+
ForeignKey("workbooks.id"),
|
|
65
|
+
nullable=True,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Original query and configuration
|
|
69
|
+
original_query = Column(Text, nullable=False)
|
|
70
|
+
research_config = Column(Text, nullable=True) # JSON string of config
|
|
71
|
+
|
|
72
|
+
# Execution status
|
|
73
|
+
status = Column(
|
|
74
|
+
"status",
|
|
75
|
+
Enum(DeepResearchStatusEnum),
|
|
76
|
+
default=DeepResearchStatusEnum.NOT_STARTED,
|
|
77
|
+
nullable=False,
|
|
78
|
+
)
|
|
79
|
+
current_phase = Column(String(50), nullable=True)
|
|
80
|
+
|
|
81
|
+
# AWS Step Functions tracking
|
|
82
|
+
step_function_arn = Column(String(512), nullable=True)
|
|
83
|
+
step_function_execution_arn = Column(String(512), nullable=True)
|
|
84
|
+
|
|
85
|
+
# Progress tracking
|
|
86
|
+
total_subtasks = Column(Integer, nullable=True, default=0)
|
|
87
|
+
completed_subtasks = Column(Integer, nullable=True, default=0)
|
|
88
|
+
failed_subtasks = Column(Integer, nullable=True, default=0)
|
|
89
|
+
|
|
90
|
+
# Human-in-the-loop state
|
|
91
|
+
hitl_status = Column(
|
|
92
|
+
"hitl_status",
|
|
93
|
+
Enum(HITLStatusEnum),
|
|
94
|
+
default=HITLStatusEnum.NONE,
|
|
95
|
+
nullable=False,
|
|
96
|
+
)
|
|
97
|
+
hitl_type = Column(String(50), nullable=True) # clarification, scope_approval, review
|
|
98
|
+
hitl_questions = Column(Text, nullable=True) # JSON array of questions
|
|
99
|
+
hitl_responses = Column(Text, nullable=True) # JSON object of responses
|
|
100
|
+
hitl_task_token = Column(String(1024), nullable=True) # Step Functions callback token
|
|
101
|
+
hitl_requested_at = Column(DateTime, nullable=True)
|
|
102
|
+
hitl_responded_at = Column(DateTime, nullable=True)
|
|
103
|
+
|
|
104
|
+
# Results storage
|
|
105
|
+
final_report_s3_key = Column(String(512), nullable=True)
|
|
106
|
+
executive_summary = Column(Text, nullable=True)
|
|
107
|
+
smart_grid_id = Column(
|
|
108
|
+
Integer,
|
|
109
|
+
ForeignKey("smart_grids.id"),
|
|
110
|
+
nullable=True,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# Metadata
|
|
114
|
+
total_citations = Column(Integer, nullable=True, default=0)
|
|
115
|
+
average_confidence = Column(Float, nullable=True)
|
|
116
|
+
total_documents_analyzed = Column(Integer, nullable=True, default=0)
|
|
117
|
+
|
|
118
|
+
# V2 Architecture Fields (Agentic Units)
|
|
119
|
+
architecture_version = Column(String(10), default="v1") # "v1" = old DAG, "v2" = agentic units
|
|
120
|
+
|
|
121
|
+
# Orchestration state (V2)
|
|
122
|
+
current_iteration = Column(Integer, default=0) # Plan-Execute-Evaluate cycle count
|
|
123
|
+
max_iterations = Column(Integer, default=10)
|
|
124
|
+
token_budget = Column(Integer, default=100000)
|
|
125
|
+
tokens_used = Column(Integer, default=0)
|
|
126
|
+
|
|
127
|
+
# Unit tracking (V2)
|
|
128
|
+
total_units = Column(Integer, default=0)
|
|
129
|
+
completed_units = Column(Integer, default=0)
|
|
130
|
+
|
|
131
|
+
# Evaluation state (V2)
|
|
132
|
+
last_evaluation = Column(Text, nullable=True) # JSON: Last evaluator output
|
|
133
|
+
objective_confidence = Column(Float, nullable=True) # Overall confidence
|
|
134
|
+
|
|
135
|
+
# Error handling
|
|
136
|
+
error_message = Column(Text, nullable=True)
|
|
137
|
+
retry_count = Column(Integer, nullable=True, default=0)
|
|
138
|
+
|
|
139
|
+
# Soft delete and timestamps
|
|
140
|
+
is_deleted = Column(Boolean, nullable=True)
|
|
141
|
+
created_at = Column(
|
|
142
|
+
DateTime,
|
|
143
|
+
nullable=False,
|
|
144
|
+
default=lambda: datetime.utcnow(),
|
|
145
|
+
)
|
|
146
|
+
updated_at = Column(
|
|
147
|
+
DateTime,
|
|
148
|
+
nullable=False,
|
|
149
|
+
default=lambda: datetime.utcnow(),
|
|
150
|
+
onupdate=lambda: datetime.utcnow(),
|
|
151
|
+
)
|
|
152
|
+
completed_at = Column(DateTime, nullable=True)
|
|
153
|
+
|
|
154
|
+
# ORM Relationships
|
|
155
|
+
subtasks = relationship(
|
|
156
|
+
"DeepResearchSubTaskModel",
|
|
157
|
+
primaryjoin="and_(DeepResearchSessionModel.id==DeepResearchSubTaskModel.session_id, "
|
|
158
|
+
"or_(DeepResearchSubTaskModel.is_deleted==False, DeepResearchSubTaskModel.is_deleted==None))",
|
|
159
|
+
order_by="DeepResearchSubTaskModel.sequence_number",
|
|
160
|
+
back_populates="session",
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# V2: Agentic Units relationship
|
|
164
|
+
agentic_units = relationship(
|
|
165
|
+
"DeepResearchAgenticUnitModel",
|
|
166
|
+
primaryjoin="and_(DeepResearchSessionModel.id==DeepResearchAgenticUnitModel.session_id, "
|
|
167
|
+
"or_(DeepResearchAgenticUnitModel.is_deleted==False, DeepResearchAgenticUnitModel.is_deleted==None))",
|
|
168
|
+
order_by="DeepResearchAgenticUnitModel.wave_number",
|
|
169
|
+
back_populates="session",
|
|
170
|
+
)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Schemas for Deep Research Sessions."""
|
|
2
|
+
from marshmallow import Schema, fields, validate
|
|
3
|
+
|
|
4
|
+
from .models import DeepResearchStatusEnum, HITLStatusEnum
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class DeepResearchSessionResourceSchema(Schema):
|
|
8
|
+
"""Schema for DeepResearchSessionModel."""
|
|
9
|
+
|
|
10
|
+
not_blank = validate.Length(min=1, error="Field cannot be blank")
|
|
11
|
+
|
|
12
|
+
id = fields.Integer(dump_only=True)
|
|
13
|
+
user_id = fields.String(required=True, validate=not_blank)
|
|
14
|
+
org_id = fields.String(allow_none=True)
|
|
15
|
+
workbook_id = fields.Integer(allow_none=True)
|
|
16
|
+
|
|
17
|
+
# Query and config
|
|
18
|
+
original_query = fields.String(required=True)
|
|
19
|
+
research_config = fields.String(allow_none=True)
|
|
20
|
+
|
|
21
|
+
# Status
|
|
22
|
+
status = fields.Enum(DeepResearchStatusEnum, by_value=True)
|
|
23
|
+
current_phase = fields.String(allow_none=True)
|
|
24
|
+
|
|
25
|
+
# Step Functions
|
|
26
|
+
step_function_arn = fields.String(allow_none=True)
|
|
27
|
+
step_function_execution_arn = fields.String(allow_none=True)
|
|
28
|
+
|
|
29
|
+
# Progress
|
|
30
|
+
total_subtasks = fields.Integer(allow_none=True)
|
|
31
|
+
completed_subtasks = fields.Integer(allow_none=True)
|
|
32
|
+
failed_subtasks = fields.Integer(allow_none=True)
|
|
33
|
+
|
|
34
|
+
# HITL
|
|
35
|
+
hitl_status = fields.Enum(HITLStatusEnum, by_value=True)
|
|
36
|
+
hitl_type = fields.String(allow_none=True)
|
|
37
|
+
hitl_questions = fields.String(allow_none=True)
|
|
38
|
+
hitl_responses = fields.String(allow_none=True)
|
|
39
|
+
hitl_task_token = fields.String(allow_none=True)
|
|
40
|
+
hitl_requested_at = fields.DateTime(allow_none=True)
|
|
41
|
+
hitl_responded_at = fields.DateTime(allow_none=True)
|
|
42
|
+
|
|
43
|
+
# Results
|
|
44
|
+
final_report_s3_key = fields.String(allow_none=True)
|
|
45
|
+
executive_summary = fields.String(allow_none=True)
|
|
46
|
+
smart_grid_id = fields.Integer(allow_none=True)
|
|
47
|
+
|
|
48
|
+
# Metadata
|
|
49
|
+
total_citations = fields.Integer(allow_none=True)
|
|
50
|
+
average_confidence = fields.Float(allow_none=True)
|
|
51
|
+
total_documents_analyzed = fields.Integer(allow_none=True)
|
|
52
|
+
|
|
53
|
+
# Error handling
|
|
54
|
+
error_message = fields.String(allow_none=True)
|
|
55
|
+
retry_count = fields.Integer(allow_none=True)
|
|
56
|
+
|
|
57
|
+
# Timestamps
|
|
58
|
+
is_deleted = fields.Boolean(allow_none=True)
|
|
59
|
+
created_at = fields.DateTime(dump_only=True)
|
|
60
|
+
updated_at = fields.DateTime(dump_only=True)
|
|
61
|
+
completed_at = fields.DateTime(allow_none=True)
|
|
62
|
+
|
|
63
|
+
# Nested relationships (dump only)
|
|
64
|
+
subtasks = fields.Nested(
|
|
65
|
+
"DeepResearchSubTaskResourceSchema",
|
|
66
|
+
many=True,
|
|
67
|
+
dump_only=True,
|
|
68
|
+
exclude=("session_id",),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class DeepResearchSessionCreateSchema(Schema):
|
|
73
|
+
"""Schema for creating a new Deep Research Session."""
|
|
74
|
+
|
|
75
|
+
not_blank = validate.Length(min=1, error="Field cannot be blank")
|
|
76
|
+
|
|
77
|
+
original_query = fields.String(required=True, validate=not_blank)
|
|
78
|
+
workbook_id = fields.Integer(allow_none=True)
|
|
79
|
+
research_config = fields.Dict(allow_none=True) # Will be serialized to JSON
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class DeepResearchSessionProgressSchema(Schema):
|
|
83
|
+
"""Schema for returning session progress."""
|
|
84
|
+
|
|
85
|
+
id = fields.Integer()
|
|
86
|
+
status = fields.Enum(DeepResearchStatusEnum, by_value=True)
|
|
87
|
+
current_phase = fields.String(allow_none=True)
|
|
88
|
+
total_subtasks = fields.Integer()
|
|
89
|
+
completed_subtasks = fields.Integer()
|
|
90
|
+
failed_subtasks = fields.Integer()
|
|
91
|
+
hitl_status = fields.Enum(HITLStatusEnum, by_value=True)
|
|
92
|
+
hitl_type = fields.String(allow_none=True)
|
|
93
|
+
hitl_questions = fields.String(allow_none=True)
|
|
94
|
+
error_message = fields.String(allow_none=True)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Deep Research SubTask model and schema exports."""
|
|
2
|
+
from .models import (
|
|
3
|
+
DeepResearchSubTaskModel,
|
|
4
|
+
SubTaskStatusEnum,
|
|
5
|
+
SubTaskTypeEnum,
|
|
6
|
+
)
|
|
7
|
+
from .schemas import (
|
|
8
|
+
DeepResearchSubTaskResourceSchema,
|
|
9
|
+
DeepResearchSubTaskSpecSchema,
|
|
10
|
+
DeepResearchSubTaskCreateSchema,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"DeepResearchSubTaskModel",
|
|
15
|
+
"SubTaskStatusEnum",
|
|
16
|
+
"SubTaskTypeEnum",
|
|
17
|
+
"DeepResearchSubTaskResourceSchema",
|
|
18
|
+
"DeepResearchSubTaskSpecSchema",
|
|
19
|
+
"DeepResearchSubTaskCreateSchema",
|
|
20
|
+
]
|