feat(ChatKnowledge): Support Financial Report Analysis (#1702)

Co-authored-by: hzh97 <2976151305@qq.com>
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: licunxing <864255598@qq.com>
This commit is contained in:
Aries-ckt
2024-07-26 13:40:54 +08:00
committed by GitHub
parent 22e0680a6a
commit 167d972093
160 changed files with 89339 additions and 795 deletions

View File

@@ -49,7 +49,6 @@ class Service(BaseService[ServeEntity, ServeRequest, ServerResponse]):
self._system_app = None
self._serve_config: ServeConfig = None
self._dao: ServeDao = dao
self._dag_manager: Optional[DAGManager] = None
self._flow_factory: FlowFactory = FlowFactory()
self._dbgpts_loader: Optional[DBGPTsLoader] = None
@@ -61,6 +60,8 @@ class Service(BaseService[ServeEntity, ServeRequest, ServerResponse]):
Args:
system_app (SystemApp): The system app
"""
super().init_app(system_app)
self._serve_config = ServeConfig.from_app_config(
system_app.config, SERVE_CONFIG_KEY_PREFIX
)
@@ -75,7 +76,7 @@ class Service(BaseService[ServeEntity, ServeRequest, ServerResponse]):
def before_start(self):
"""Execute before the application starts"""
self._dag_manager = DAGManager.get_instance(self._system_app)
super().before_start()
self._pre_load_dag_from_db()
self._pre_load_dag_from_dbgpts()
@@ -92,13 +93,6 @@ class Service(BaseService[ServeEntity, ServeRequest, ServerResponse]):
"""Returns the internal DAO."""
return self._dao
@property
def dag_manager(self) -> DAGManager:
"""Returns the internal DAGManager."""
if self._dag_manager is None:
raise ValueError("DAGManager is not initialized")
return self._dag_manager
@property
def dbgpts_loader(self) -> DBGPTsLoader:
"""Returns the internal DBGPTsLoader."""
@@ -524,11 +518,11 @@ class Service(BaseService[ServeEntity, ServeRequest, ServerResponse]):
status_code=404, detail=f"Flow {flow_uid}'s dag id not found"
)
dag = self.dag_manager.dag_map[dag_id]
if (
flow.flow_category != FlowCategory.CHAT_FLOW
and self._parse_flow_category(dag) != FlowCategory.CHAT_FLOW
):
raise ValueError(f"Flow {flow_uid} is not a chat flow")
# if (
# flow.flow_category != FlowCategory.CHAT_FLOW
# and self._parse_flow_category(dag) != FlowCategory.CHAT_FLOW
# ):
# raise ValueError(f"Flow {flow_uid} is not a chat flow")
leaf_nodes = dag.leaf_nodes
if len(leaf_nodes) != 1:
raise ValueError("Chat Flow just support one leaf node in dag")