Procházet zdrojové kódy

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>
tags/1.2.0
jiangbo721 před 7 měsíci
rodič
revize
a1aa325ce3
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 3
- 3
api/controllers/service_api/app/workflow.py Zobrazit soubor

@@ -54,7 +54,7 @@ workflow_run_fields = {
class WorkflowRunDetailApi(Resource):
@validate_app_token
@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
"""
@@ -62,7 +62,7 @@ class WorkflowRunDetailApi(Resource):
if app_mode != AppMode.WORKFLOW:
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


@@ -163,6 +163,6 @@ class WorkflowAppLogApi(Resource):


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(WorkflowAppLogApi, "/workflows/logs")

+ 3
- 4
api/core/app/task_pipeline/workflow_cycle_manage.py Zobrazit soubor

@@ -44,6 +44,7 @@ from core.app.entities.task_entities import (
WorkflowFinishStreamResponse,
WorkflowStartStreamResponse,
)
from core.app.task_pipeline.exc import WorkflowRunNotFoundError
from core.file import FILE_MODEL_IDENTITY, File
from core.model_runtime.utils.encoders import jsonable_encoder
from core.ops.entities.trace_entity import TraceTaskName
@@ -66,8 +67,6 @@ from models.workflow import (
WorkflowRunStatus,
)

from .exc import WorkflowRunNotFoundError


class WorkflowCycleManage:
def __init__(
@@ -166,7 +165,7 @@ class WorkflowCycleManage:

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.elapsed_time = time.perf_counter() - start_at
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)
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.elapsed_time = time.perf_counter() - start_at
workflow_run.total_tokens = total_tokens

+ 2
- 2
api/core/rag/index_processor/constant/built_in_field.py Zobrazit soubor

@@ -1,7 +1,7 @@
from enum import Enum
from enum import Enum, StrEnum


class BuiltInField(str, Enum):
class BuiltInField(StrEnum):
document_name = "document_name"
uploader = "uploader"
upload_date = "upload_date"

+ 2
- 2
api/core/rag/index_processor/constant/index_type.py Zobrazit soubor

@@ -1,7 +1,7 @@
from enum import Enum
from enum import StrEnum


class IndexType(str, Enum):
class IndexType(StrEnum):
PARAGRAPH_INDEX = "text_model"
QA_INDEX = "qa_model"
PARENT_CHILD_INDEX = "hierarchical_model"

+ 2
- 0
api/core/rag/index_processor/processor/parent_child_index_processor.py Zobrazit soubor

@@ -39,6 +39,8 @@ class ParentChildIndexProcessor(BaseIndexProcessor):
all_documents = [] # type: ignore
if rules.parent_mode == ParentMode.PARAGRAPH:
# Split the text documents into nodes.
if not rules.segmentation:
raise ValueError("No segmentation found in rules.")
splitter = self._get_splitter(
processing_rule_mode=process_rule.get("mode"),
max_tokens=rules.segmentation.max_tokens,

+ 2
- 2
api/models/model.py Zobrazit soubor

@@ -791,7 +791,7 @@ class Conversation(db.Model): # type: ignore[name-defined]
WorkflowRunStatus.SUCCEEDED: 0,
WorkflowRunStatus.FAILED: 0,
WorkflowRunStatus.STOPPED: 0,
WorkflowRunStatus.PARTIAL_SUCCESSED: 0,
WorkflowRunStatus.PARTIAL_SUCCEEDED: 0,
}

for message in messages:
@@ -802,7 +802,7 @@ class Conversation(db.Model): # type: ignore[name-defined]
{
"success": status_counts[WorkflowRunStatus.SUCCEEDED],
"failed": status_counts[WorkflowRunStatus.FAILED],
"partial_success": status_counts[WorkflowRunStatus.PARTIAL_SUCCESSED],
"partial_success": status_counts[WorkflowRunStatus.PARTIAL_SUCCEEDED],
}
if messages
else None

+ 2
- 2
api/models/workflow.py Zobrazit soubor

@@ -109,7 +109,7 @@ class Workflow(Base):
tenant_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)
version: Mapped[str]
version: Mapped[str] = mapped_column(db.String(255), nullable=False)
marked_name: Mapped[str] = mapped_column(default="", server_default="")
marked_comment: Mapped[str] = mapped_column(default="", server_default="")
graph: Mapped[str] = mapped_column(sa.Text)
@@ -352,7 +352,7 @@ class WorkflowRunStatus(StrEnum):
SUCCEEDED = "succeeded"
FAILED = "failed"
STOPPED = "stopped"
PARTIAL_SUCCESSED = "partial-succeeded"
PARTIAL_SUCCEEDED = "partial-succeeded"


class WorkflowRun(Base):

+ 2
- 2
api/services/entities/knowledge_entities/knowledge_entities.py Zobrazit soubor

@@ -1,4 +1,4 @@
from enum import Enum
from enum import StrEnum
from typing import Literal, Optional

from pydantic import BaseModel
@@ -11,7 +11,7 @@ class SegmentUpdateEntity(BaseModel):
enabled: Optional[bool] = None


class ParentMode(str, Enum):
class ParentMode(StrEnum):
FULL_DOC = "full-doc"
PARAGRAPH = "paragraph"


+ 4
- 4
web/app/components/develop/template/template_workflow.zh.mdx Zobrazit soubor

@@ -318,7 +318,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
---

<Heading
url='/workflows/run/:workflow_id'
url='/workflows/run/:workflow_run_id'
method='GET'
title='获取workflow执行情况'
name='#get-workflow-run-detail'
@@ -327,7 +327,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
<Col>
根据 workflow 执行 ID 获取 workflow 任务当前执行结果
### Path
- `workflow_id` (string) workflow 执行 ID,可在流式返回 Chunk 中获取
- `workflow_run_id` (string) workflow_run_id,可在流式返回 Chunk 中获取
### Response
- `id` (string) workflow 执行 ID
- `workflow_id` (string) 关联的 Workflow ID
@@ -343,9 +343,9 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
</Col>
<Col sticky>
### 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' }}
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 'Content-Type: application/json'
```

Načítá se…
Zrušit
Uložit