mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-06-04 11:14:10 +08:00
Chore/code format and Repair commit_id 3254018d more deleted codes and Fix naming error ambiguity between workflow_run_id and workflow_id (#17075)
Co-authored-by: 刘江波 <jiangbo721@163.com>
This commit is contained in:
parent
34cba83ac4
commit
a1aa325ce3
@ -54,7 +54,7 @@ workflow_run_fields = {
|
|||||||
class WorkflowRunDetailApi(Resource):
|
class WorkflowRunDetailApi(Resource):
|
||||||
@validate_app_token
|
@validate_app_token
|
||||||
@marshal_with(workflow_run_fields)
|
@marshal_with(workflow_run_fields)
|
||||||
def get(self, app_model: App, workflow_id: str):
|
def get(self, app_model: App, workflow_run_id: str):
|
||||||
"""
|
"""
|
||||||
Get a workflow task running detail
|
Get a workflow task running detail
|
||||||
"""
|
"""
|
||||||
@ -62,7 +62,7 @@ class WorkflowRunDetailApi(Resource):
|
|||||||
if app_mode != AppMode.WORKFLOW:
|
if app_mode != AppMode.WORKFLOW:
|
||||||
raise NotWorkflowAppError()
|
raise NotWorkflowAppError()
|
||||||
|
|
||||||
workflow_run = db.session.query(WorkflowRun).filter(WorkflowRun.id == workflow_id).first()
|
workflow_run = db.session.query(WorkflowRun).filter(WorkflowRun.id == workflow_run_id).first()
|
||||||
return workflow_run
|
return workflow_run
|
||||||
|
|
||||||
|
|
||||||
@ -163,6 +163,6 @@ class WorkflowAppLogApi(Resource):
|
|||||||
|
|
||||||
|
|
||||||
api.add_resource(WorkflowRunApi, "/workflows/run")
|
api.add_resource(WorkflowRunApi, "/workflows/run")
|
||||||
api.add_resource(WorkflowRunDetailApi, "/workflows/run/<string:workflow_id>")
|
api.add_resource(WorkflowRunDetailApi, "/workflows/run/<string:workflow_run_id>")
|
||||||
api.add_resource(WorkflowTaskStopApi, "/workflows/tasks/<string:task_id>/stop")
|
api.add_resource(WorkflowTaskStopApi, "/workflows/tasks/<string:task_id>/stop")
|
||||||
api.add_resource(WorkflowAppLogApi, "/workflows/logs")
|
api.add_resource(WorkflowAppLogApi, "/workflows/logs")
|
||||||
|
@ -44,6 +44,7 @@ from core.app.entities.task_entities import (
|
|||||||
WorkflowFinishStreamResponse,
|
WorkflowFinishStreamResponse,
|
||||||
WorkflowStartStreamResponse,
|
WorkflowStartStreamResponse,
|
||||||
)
|
)
|
||||||
|
from core.app.task_pipeline.exc import WorkflowRunNotFoundError
|
||||||
from core.file import FILE_MODEL_IDENTITY, File
|
from core.file import FILE_MODEL_IDENTITY, File
|
||||||
from core.model_runtime.utils.encoders import jsonable_encoder
|
from core.model_runtime.utils.encoders import jsonable_encoder
|
||||||
from core.ops.entities.trace_entity import TraceTaskName
|
from core.ops.entities.trace_entity import TraceTaskName
|
||||||
@ -66,8 +67,6 @@ from models.workflow import (
|
|||||||
WorkflowRunStatus,
|
WorkflowRunStatus,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .exc import WorkflowRunNotFoundError
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowCycleManage:
|
class WorkflowCycleManage:
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -166,7 +165,7 @@ class WorkflowCycleManage:
|
|||||||
|
|
||||||
outputs = WorkflowEntry.handle_special_values(outputs)
|
outputs = WorkflowEntry.handle_special_values(outputs)
|
||||||
|
|
||||||
workflow_run.status = WorkflowRunStatus.SUCCEEDED.value
|
workflow_run.status = WorkflowRunStatus.SUCCEEDED
|
||||||
workflow_run.outputs = json.dumps(outputs or {})
|
workflow_run.outputs = json.dumps(outputs or {})
|
||||||
workflow_run.elapsed_time = time.perf_counter() - start_at
|
workflow_run.elapsed_time = time.perf_counter() - start_at
|
||||||
workflow_run.total_tokens = total_tokens
|
workflow_run.total_tokens = total_tokens
|
||||||
@ -201,7 +200,7 @@ class WorkflowCycleManage:
|
|||||||
workflow_run = self._get_workflow_run(session=session, workflow_run_id=workflow_run_id)
|
workflow_run = self._get_workflow_run(session=session, workflow_run_id=workflow_run_id)
|
||||||
outputs = WorkflowEntry.handle_special_values(dict(outputs) if outputs else None)
|
outputs = WorkflowEntry.handle_special_values(dict(outputs) if outputs else None)
|
||||||
|
|
||||||
workflow_run.status = WorkflowRunStatus.PARTIAL_SUCCESSED.value
|
workflow_run.status = WorkflowRunStatus.PARTIAL_SUCCEEDED.value
|
||||||
workflow_run.outputs = json.dumps(outputs or {})
|
workflow_run.outputs = json.dumps(outputs or {})
|
||||||
workflow_run.elapsed_time = time.perf_counter() - start_at
|
workflow_run.elapsed_time = time.perf_counter() - start_at
|
||||||
workflow_run.total_tokens = total_tokens
|
workflow_run.total_tokens = total_tokens
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from enum import Enum
|
from enum import Enum, StrEnum
|
||||||
|
|
||||||
|
|
||||||
class BuiltInField(str, Enum):
|
class BuiltInField(StrEnum):
|
||||||
document_name = "document_name"
|
document_name = "document_name"
|
||||||
uploader = "uploader"
|
uploader = "uploader"
|
||||||
upload_date = "upload_date"
|
upload_date = "upload_date"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
|
|
||||||
|
|
||||||
class IndexType(str, Enum):
|
class IndexType(StrEnum):
|
||||||
PARAGRAPH_INDEX = "text_model"
|
PARAGRAPH_INDEX = "text_model"
|
||||||
QA_INDEX = "qa_model"
|
QA_INDEX = "qa_model"
|
||||||
PARENT_CHILD_INDEX = "hierarchical_model"
|
PARENT_CHILD_INDEX = "hierarchical_model"
|
||||||
|
@ -39,6 +39,8 @@ class ParentChildIndexProcessor(BaseIndexProcessor):
|
|||||||
all_documents = [] # type: ignore
|
all_documents = [] # type: ignore
|
||||||
if rules.parent_mode == ParentMode.PARAGRAPH:
|
if rules.parent_mode == ParentMode.PARAGRAPH:
|
||||||
# Split the text documents into nodes.
|
# Split the text documents into nodes.
|
||||||
|
if not rules.segmentation:
|
||||||
|
raise ValueError("No segmentation found in rules.")
|
||||||
splitter = self._get_splitter(
|
splitter = self._get_splitter(
|
||||||
processing_rule_mode=process_rule.get("mode"),
|
processing_rule_mode=process_rule.get("mode"),
|
||||||
max_tokens=rules.segmentation.max_tokens,
|
max_tokens=rules.segmentation.max_tokens,
|
||||||
|
@ -791,7 +791,7 @@ class Conversation(db.Model): # type: ignore[name-defined]
|
|||||||
WorkflowRunStatus.SUCCEEDED: 0,
|
WorkflowRunStatus.SUCCEEDED: 0,
|
||||||
WorkflowRunStatus.FAILED: 0,
|
WorkflowRunStatus.FAILED: 0,
|
||||||
WorkflowRunStatus.STOPPED: 0,
|
WorkflowRunStatus.STOPPED: 0,
|
||||||
WorkflowRunStatus.PARTIAL_SUCCESSED: 0,
|
WorkflowRunStatus.PARTIAL_SUCCEEDED: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
for message in messages:
|
for message in messages:
|
||||||
@ -802,7 +802,7 @@ class Conversation(db.Model): # type: ignore[name-defined]
|
|||||||
{
|
{
|
||||||
"success": status_counts[WorkflowRunStatus.SUCCEEDED],
|
"success": status_counts[WorkflowRunStatus.SUCCEEDED],
|
||||||
"failed": status_counts[WorkflowRunStatus.FAILED],
|
"failed": status_counts[WorkflowRunStatus.FAILED],
|
||||||
"partial_success": status_counts[WorkflowRunStatus.PARTIAL_SUCCESSED],
|
"partial_success": status_counts[WorkflowRunStatus.PARTIAL_SUCCEEDED],
|
||||||
}
|
}
|
||||||
if messages
|
if messages
|
||||||
else None
|
else None
|
||||||
|
@ -109,7 +109,7 @@ class Workflow(Base):
|
|||||||
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
||||||
app_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
app_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
||||||
type: Mapped[str] = mapped_column(db.String(255), nullable=False)
|
type: Mapped[str] = mapped_column(db.String(255), nullable=False)
|
||||||
version: Mapped[str]
|
version: Mapped[str] = mapped_column(db.String(255), nullable=False)
|
||||||
marked_name: Mapped[str] = mapped_column(default="", server_default="")
|
marked_name: Mapped[str] = mapped_column(default="", server_default="")
|
||||||
marked_comment: Mapped[str] = mapped_column(default="", server_default="")
|
marked_comment: Mapped[str] = mapped_column(default="", server_default="")
|
||||||
graph: Mapped[str] = mapped_column(sa.Text)
|
graph: Mapped[str] = mapped_column(sa.Text)
|
||||||
@ -352,7 +352,7 @@ class WorkflowRunStatus(StrEnum):
|
|||||||
SUCCEEDED = "succeeded"
|
SUCCEEDED = "succeeded"
|
||||||
FAILED = "failed"
|
FAILED = "failed"
|
||||||
STOPPED = "stopped"
|
STOPPED = "stopped"
|
||||||
PARTIAL_SUCCESSED = "partial-succeeded"
|
PARTIAL_SUCCEEDED = "partial-succeeded"
|
||||||
|
|
||||||
|
|
||||||
class WorkflowRun(Base):
|
class WorkflowRun(Base):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from enum import Enum
|
from enum import StrEnum
|
||||||
from typing import Literal, Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@ -11,7 +11,7 @@ class SegmentUpdateEntity(BaseModel):
|
|||||||
enabled: Optional[bool] = None
|
enabled: Optional[bool] = None
|
||||||
|
|
||||||
|
|
||||||
class ParentMode(str, Enum):
|
class ParentMode(StrEnum):
|
||||||
FULL_DOC = "full-doc"
|
FULL_DOC = "full-doc"
|
||||||
PARAGRAPH = "paragraph"
|
PARAGRAPH = "paragraph"
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
|
|||||||
---
|
---
|
||||||
|
|
||||||
<Heading
|
<Heading
|
||||||
url='/workflows/run/:workflow_id'
|
url='/workflows/run/:workflow_run_id'
|
||||||
method='GET'
|
method='GET'
|
||||||
title='获取workflow执行情况'
|
title='获取workflow执行情况'
|
||||||
name='#get-workflow-run-detail'
|
name='#get-workflow-run-detail'
|
||||||
@ -327,7 +327,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
|
|||||||
<Col>
|
<Col>
|
||||||
根据 workflow 执行 ID 获取 workflow 任务当前执行结果
|
根据 workflow 执行 ID 获取 workflow 任务当前执行结果
|
||||||
### Path
|
### Path
|
||||||
- `workflow_id` (string) workflow 执行 ID,可在流式返回 Chunk 中获取
|
- `workflow_run_id` (string) workflow_run_id,可在流式返回 Chunk 中获取
|
||||||
### Response
|
### Response
|
||||||
- `id` (string) workflow 执行 ID
|
- `id` (string) workflow 执行 ID
|
||||||
- `workflow_id` (string) 关联的 Workflow ID
|
- `workflow_id` (string) 关联的 Workflow ID
|
||||||
@ -343,9 +343,9 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
|
|||||||
</Col>
|
</Col>
|
||||||
<Col sticky>
|
<Col sticky>
|
||||||
### Request Example
|
### Request Example
|
||||||
<CodeGroup title="Request" tag="GET" label="/workflows/run/:workflow_id" targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_id' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json'`}>
|
<CodeGroup title="Request" tag="GET" label="/workflows/run/:workflow_run_id" targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json'`}>
|
||||||
```bash {{ title: 'cURL' }}
|
```bash {{ title: 'cURL' }}
|
||||||
curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_id' \
|
curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \
|
||||||
-H 'Authorization: Bearer {api_key}' \
|
-H 'Authorization: Bearer {api_key}' \
|
||||||
-H 'Content-Type: application/json'
|
-H 'Content-Type: application/json'
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user