mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-15 14:11:14 +00:00
feat: (0.6)New UI (#1855)
Co-authored-by: 夏姜 <wenfengjiang.jwf@digital-engine.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: wb-lh513319 <wb-lh513319@alibaba-inc.com> Co-authored-by: csunny <cfqsunny@163.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from fastapi.security.http import HTTPAuthorizationCredentials, HTTPBearer
|
||||
|
||||
from dbgpt.component import SystemApp
|
||||
from dbgpt.core.awel.flow import ResourceMetadata, ViewMetadata
|
||||
from dbgpt.core.awel.flow.flow_factory import FlowCategory
|
||||
from dbgpt.serve.core import Result
|
||||
from dbgpt.util import PaginationResult
|
||||
|
||||
@@ -172,6 +173,35 @@ async def get_flows(
|
||||
return Result.succ(flow)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/chat/flows",
|
||||
response_model=Result[PaginationResult[ServerResponse]],
|
||||
dependencies=[Depends(check_api_key)],
|
||||
)
|
||||
async def query_chat_flows(
|
||||
user_name: Optional[str] = Query(default=None, description="user name"),
|
||||
sys_code: Optional[str] = Query(default=None, description="system code"),
|
||||
page: int = Query(default=1, description="current page"),
|
||||
page_size: int = Query(default=20, description="page size"),
|
||||
name: Optional[str] = Query(default=None, description="flow name"),
|
||||
uid: Optional[str] = Query(default=None, description="flow uid"),
|
||||
service: Service = Depends(get_service),
|
||||
) -> Result[PaginationResult[ServerResponse]]:
|
||||
return Result.succ(
|
||||
service.get_list_by_page(
|
||||
{
|
||||
"user_name": user_name,
|
||||
"sys_code": sys_code,
|
||||
"name": name,
|
||||
"uid": uid,
|
||||
"flow_category": [FlowCategory.CHAT_AGENT, FlowCategory.CHAT_FLOW],
|
||||
},
|
||||
page,
|
||||
page_size,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/flows",
|
||||
response_model=Result[PaginationResult[ServerResponse]],
|
||||
|
@@ -6,6 +6,7 @@ import schedule
|
||||
from fastapi import HTTPException
|
||||
|
||||
from dbgpt._private.pydantic import model_to_json
|
||||
from dbgpt.agent import AgentDummyTrigger
|
||||
from dbgpt.component import SystemApp
|
||||
from dbgpt.core.awel import DAG, BaseOperator, CommonLLMHttpRequestBody
|
||||
from dbgpt.core.awel.dag.dag_manager import DAGManager
|
||||
@@ -258,7 +259,7 @@ class Service(BaseService[ServeEntity, ServeRequest, ServerResponse]):
|
||||
Returns:
|
||||
ServerResponse: The response
|
||||
"""
|
||||
new_state = request.state
|
||||
new_state = State.DEPLOYED
|
||||
try:
|
||||
# Try to build the dag from the request
|
||||
if request.define_type == "json":
|
||||
@@ -548,18 +549,28 @@ class Service(BaseService[ServeEntity, ServeRequest, ServerResponse]):
|
||||
or not isinstance(leaf_nodes[0], BaseOperator)
|
||||
):
|
||||
return FlowCategory.COMMON
|
||||
|
||||
leaf_node = cast(BaseOperator, leaf_nodes[0])
|
||||
if not leaf_node.metadata or not leaf_node.metadata.outputs:
|
||||
return FlowCategory.COMMON
|
||||
|
||||
common_http_trigger = False
|
||||
agent_trigger = False
|
||||
for trigger in triggers:
|
||||
if isinstance(trigger, CommonLLMHttpTrigger):
|
||||
common_http_trigger = True
|
||||
break
|
||||
leaf_node = cast(BaseOperator, leaf_nodes[0])
|
||||
if not leaf_node.metadata or not leaf_node.metadata.outputs:
|
||||
return FlowCategory.COMMON
|
||||
|
||||
if isinstance(trigger, AgentDummyTrigger):
|
||||
agent_trigger = True
|
||||
break
|
||||
|
||||
output = leaf_node.metadata.outputs[0]
|
||||
try:
|
||||
real_class = _get_type_cls(output.type_cls)
|
||||
if common_http_trigger and is_chat_flow_type(real_class, is_class=True):
|
||||
if agent_trigger:
|
||||
return FlowCategory.CHAT_AGENT
|
||||
elif common_http_trigger and is_chat_flow_type(real_class, is_class=True):
|
||||
return FlowCategory.CHAT_FLOW
|
||||
except Exception:
|
||||
return FlowCategory.COMMON
|
||||
|
Reference in New Issue
Block a user