mirror of
https://github.com/langgenius/dify.git
synced 2026-07-20 09:38:32 +08:00
fix(api): serialize trial workflow conversation variables (#39038)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
7dfd84472f
commit
cb41fb3e76
@ -58,6 +58,7 @@ from extensions.ext_database import db
|
||||
from extensions.ext_redis import redis_client
|
||||
from factories import file_factory, variable_factory
|
||||
from fields.base import ResponseModel
|
||||
from fields.conversation_variable_fields import WorkflowConversationVariableResponse
|
||||
from fields.member_fields import SimpleAccount
|
||||
from fields.workflow_run_fields import WorkflowRunNodeExecutionResponse
|
||||
from graphon.enums import NodeType
|
||||
@ -238,21 +239,6 @@ class WorkflowOnlineUsersPayload(BaseModel):
|
||||
return list(dict.fromkeys(app_id.strip() for app_id in app_ids if app_id.strip()))
|
||||
|
||||
|
||||
class WorkflowConversationVariableResponse(ResponseModel):
|
||||
id: str
|
||||
name: str
|
||||
value_type: str
|
||||
value: Any
|
||||
description: str
|
||||
|
||||
@field_validator("value_type", mode="before")
|
||||
@classmethod
|
||||
def _serialize_value_type(cls, value: Any) -> str:
|
||||
if hasattr(value, "exposed_type"):
|
||||
return str(value.exposed_type())
|
||||
return str(value)
|
||||
|
||||
|
||||
class PipelineVariableResponse(ResponseModel):
|
||||
label: str
|
||||
variable: str
|
||||
|
||||
@ -60,6 +60,7 @@ from core.errors.error import (
|
||||
from extensions.ext_database import db
|
||||
from extensions.ext_redis import redis_client
|
||||
from fields.base import ResponseModel
|
||||
from fields.conversation_variable_fields import WorkflowConversationVariableResponse
|
||||
from fields.message_fields import SuggestedQuestionsResponse
|
||||
from graphon.graph_engine.manager import GraphEngineManager
|
||||
from graphon.model_runtime.errors.invoke import InvokeError
|
||||
@ -373,7 +374,7 @@ class TrialWorkflowResponse(ResponseModel):
|
||||
updated_at: int | None = None
|
||||
tool_published: bool | None = None
|
||||
environment_variables: list[JsonObject] = Field(default_factory=list)
|
||||
conversation_variables: list[JsonObject] = Field(default_factory=list)
|
||||
conversation_variables: list[WorkflowConversationVariableResponse] = Field(default_factory=list)
|
||||
rag_pipeline_variables: list[JsonObject] = Field(default_factory=list)
|
||||
|
||||
@field_validator("created_at", "updated_at", mode="before")
|
||||
|
||||
@ -60,6 +60,21 @@ class ConversationVariableResponse(ResponseModel):
|
||||
return to_timestamp(value)
|
||||
|
||||
|
||||
class WorkflowConversationVariableResponse(ResponseModel):
|
||||
id: str
|
||||
name: str
|
||||
value_type: str
|
||||
value: Any
|
||||
description: str
|
||||
|
||||
@field_validator("value_type", mode="before")
|
||||
@classmethod
|
||||
def _serialize_value_type(cls, value: Any) -> str:
|
||||
if hasattr(value, "exposed_type"):
|
||||
return str(value.exposed_type())
|
||||
return str(value)
|
||||
|
||||
|
||||
class PaginatedConversationVariableResponse(ResponseModel):
|
||||
page: int
|
||||
limit: int
|
||||
|
||||
@ -22558,7 +22558,7 @@ Enum class for tool provider
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| conversation_variables | [ [JsonObject](#jsonobject) ] | | No |
|
||||
| conversation_variables | [ [WorkflowConversationVariableResponse](#workflowconversationvariableresponse) ] | | No |
|
||||
| created_at | integer | | No |
|
||||
| created_by | [TrialSimpleAccount](#trialsimpleaccount) | | No |
|
||||
| environment_variables | [ [JsonObject](#jsonobject) ] | | No |
|
||||
|
||||
@ -33,6 +33,7 @@ from core.errors.error import (
|
||||
QuotaExceededError,
|
||||
)
|
||||
from graphon.model_runtime.errors.invoke import InvokeError
|
||||
from graphon.variables import StringVariable
|
||||
from models import Account
|
||||
from models.account import TenantStatus
|
||||
from models.model import AppMode
|
||||
@ -1146,7 +1147,14 @@ class TestAppWorkflowApi:
|
||||
created_at=datetime(2024, 1, 1, tzinfo=UTC),
|
||||
updated_at=datetime(2024, 1, 2, tzinfo=UTC),
|
||||
environment_variables=[],
|
||||
conversation_variables=[],
|
||||
conversation_variables=[
|
||||
StringVariable(
|
||||
id="conversation-variable-1",
|
||||
name="topic",
|
||||
value="sqlite",
|
||||
selector=["conversation", "topic"],
|
||||
)
|
||||
],
|
||||
rag_pipeline_variables=[],
|
||||
get_created_by_account=MagicMock(return_value=created_by),
|
||||
get_updated_by_account=MagicMock(return_value=None),
|
||||
@ -1174,7 +1182,15 @@ class TestAppWorkflowApi:
|
||||
"updated_at": 1704153600,
|
||||
"tool_published": True,
|
||||
"environment_variables": [],
|
||||
"conversation_variables": [],
|
||||
"conversation_variables": [
|
||||
{
|
||||
"id": "conversation-variable-1",
|
||||
"name": "topic",
|
||||
"value_type": "string",
|
||||
"value": "sqlite",
|
||||
"description": "",
|
||||
}
|
||||
],
|
||||
"rag_pipeline_variables": [],
|
||||
}
|
||||
app_model.workflow_with_session.assert_called_once_with(session=session)
|
||||
|
||||
@ -111,7 +111,7 @@ export type TextToSpeechRequest = {
|
||||
export type AudioBinaryResponse = Blob | File
|
||||
|
||||
export type TrialWorkflowResponse = {
|
||||
conversation_variables?: Array<JsonObject2>
|
||||
conversation_variables?: Array<WorkflowConversationVariableResponse>
|
||||
created_at?: number | null
|
||||
created_by?: TrialSimpleAccount | null
|
||||
environment_variables?: Array<JsonObject2>
|
||||
@ -242,8 +242,12 @@ export type SystemParameters = {
|
||||
workflow_file_upload_limit: number
|
||||
}
|
||||
|
||||
export type JsonObject2 = {
|
||||
[key: string]: unknown
|
||||
export type WorkflowConversationVariableResponse = {
|
||||
description: string
|
||||
id: string
|
||||
name: string
|
||||
value: unknown
|
||||
value_type: string
|
||||
}
|
||||
|
||||
export type TrialSimpleAccount = {
|
||||
@ -252,6 +256,10 @@ export type TrialSimpleAccount = {
|
||||
name?: string | null
|
||||
}
|
||||
|
||||
export type JsonObject2 = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type TrialAppAgentMode = {
|
||||
enabled?: boolean | null
|
||||
strategy?: string | null
|
||||
|
||||
@ -217,7 +217,16 @@ export const zParameters = z.object({
|
||||
user_input_form: z.array(zJsonObject),
|
||||
})
|
||||
|
||||
export const zJsonObject2 = z.record(z.string(), z.unknown())
|
||||
/**
|
||||
* WorkflowConversationVariableResponse
|
||||
*/
|
||||
export const zWorkflowConversationVariableResponse = z.object({
|
||||
description: z.string(),
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
value: z.unknown(),
|
||||
value_type: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* TrialSimpleAccount
|
||||
@ -228,11 +237,13 @@ export const zTrialSimpleAccount = z.object({
|
||||
name: z.string().nullish(),
|
||||
})
|
||||
|
||||
export const zJsonObject2 = z.record(z.string(), z.unknown())
|
||||
|
||||
/**
|
||||
* TrialWorkflowResponse
|
||||
*/
|
||||
export const zTrialWorkflowResponse = z.object({
|
||||
conversation_variables: z.array(zJsonObject2).optional(),
|
||||
conversation_variables: z.array(zWorkflowConversationVariableResponse).optional(),
|
||||
created_at: z.int().nullish(),
|
||||
created_by: zTrialSimpleAccount.nullish(),
|
||||
environment_variables: z.array(zJsonObject2).optional(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user