mirror of https://github.com/langgenius/dify.git
70 lines
1.9 KiB
Python
70 lines
1.9 KiB
Python
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class BaseDebugEvent(BaseModel):
|
|
"""Base class for all debug events."""
|
|
|
|
timestamp: int
|
|
|
|
|
|
class ScheduleDebugEvent(BaseDebugEvent):
|
|
"""Debug event for schedule triggers."""
|
|
|
|
node_id: str
|
|
inputs: Mapping[str, Any]
|
|
|
|
@classmethod
|
|
def build_pool_key(cls, tenant_id: str, app_id: str, node_id: str) -> str:
|
|
"""Generate pool key for schedule events.
|
|
|
|
Args:
|
|
tenant_id: Tenant ID
|
|
app_id: App ID
|
|
node_id: Node ID
|
|
"""
|
|
return f"schedule_trigger_debug_waiting_pool:{tenant_id}:{app_id}:{node_id}"
|
|
|
|
|
|
class WebhookDebugEvent(BaseDebugEvent):
|
|
"""Debug event for webhook triggers."""
|
|
|
|
request_id: str
|
|
node_id: str
|
|
payload: dict[str, Any] = Field(default_factory=dict)
|
|
|
|
@classmethod
|
|
def build_pool_key(cls, tenant_id: str, app_id: str, node_id: str) -> str:
|
|
"""Generate pool key for webhook events.
|
|
|
|
Args:
|
|
tenant_id: Tenant ID
|
|
app_id: App ID
|
|
node_id: Node ID
|
|
"""
|
|
return f"webhook_trigger_debug_waiting_pool:{tenant_id}:{app_id}:{node_id}"
|
|
|
|
|
|
class PluginTriggerDebugEvent(BaseDebugEvent):
|
|
"""Debug event for plugin triggers."""
|
|
|
|
name: str
|
|
user_id: str = Field(description="This is end user id, only for trigger the event. no related with account user id")
|
|
request_id: str
|
|
subscription_id: str
|
|
provider_id: str
|
|
|
|
@classmethod
|
|
def build_pool_key(cls, tenant_id: str, provider_id: str, subscription_id: str, name: str) -> str:
|
|
"""Generate pool key for plugin trigger events.
|
|
|
|
Args:
|
|
name: Event name
|
|
tenant_id: Tenant ID
|
|
provider_id: Provider ID
|
|
subscription_id: Subscription ID
|
|
"""
|
|
return f"plugin_trigger_debug_waiting_pool:{tenant_id}:{str(provider_id)}:{subscription_id}:{name}"
|