Files
dify-plugin-sdks/python/dify_plugin/core/entities/message.py
T
Yeuoly 8f028d2832 feat: add datasource declaration handling in plugin initialization
- Implemented logic to write a datasource declaration message when a datasource configuration is present during plugin initialization.
- Introduced a new message type, `DATASOURCE_DECLARATION`, in the `InitializeMessage` class to support this functionality.
2025-05-23 19:17:15 +08:00

42 lines
988 B
Python

from enum import Enum
from pydantic import BaseModel
class SessionMessage(BaseModel):
class Type(Enum):
STREAM = "stream"
INVOKE = "invoke"
END = "end"
ERROR = "error"
type: Type
data: dict
def to_dict(self):
return {"type": self.type.value, "data": self.data}
class InitializeMessage(BaseModel):
class Type(Enum):
HANDSHAKE = "handshake"
ASSET_CHUNK = "asset_chunk"
MANIFEST_DECLARATION = "manifest_declaration"
TOOL_DECLARATION = "tool_declaration"
MODEL_DECLARATION = "model_declaration"
ENDPOINT_DECLARATION = "endpoint_declaration"
AGENT_STRATEGY_DECLARATION = "agent_strategy_declaration"
DATASOURCE_DECLARATION = "datasource_declaration"
END = "end"
class AssetChunk(BaseModel):
filename: str
data: str # base64 encoded
end: bool
class Key(BaseModel):
key: str
type: Type
data: dict | list