mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
d069c668f8
Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> Co-authored-by: chenhe <guchenhe@gmail.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn>
119 lines
2.3 KiB
Python
119 lines
2.3 KiB
Python
from enum import Enum
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk
|
|
|
|
|
|
class QueueEvent(Enum):
|
|
"""
|
|
QueueEvent enum
|
|
"""
|
|
MESSAGE = "message"
|
|
MESSAGE_REPLACE = "message-replace"
|
|
MESSAGE_END = "message-end"
|
|
RETRIEVER_RESOURCES = "retriever-resources"
|
|
ANNOTATION_REPLY = "annotation-reply"
|
|
AGENT_THOUGHT = "agent-thought"
|
|
ERROR = "error"
|
|
PING = "ping"
|
|
STOP = "stop"
|
|
|
|
|
|
class AppQueueEvent(BaseModel):
|
|
"""
|
|
QueueEvent entity
|
|
"""
|
|
event: QueueEvent
|
|
|
|
|
|
class QueueMessageEvent(AppQueueEvent):
|
|
"""
|
|
QueueMessageEvent entity
|
|
"""
|
|
event = QueueEvent.MESSAGE
|
|
chunk: LLMResultChunk
|
|
|
|
|
|
class QueueMessageReplaceEvent(AppQueueEvent):
|
|
"""
|
|
QueueMessageReplaceEvent entity
|
|
"""
|
|
event = QueueEvent.MESSAGE_REPLACE
|
|
text: str
|
|
|
|
|
|
class QueueRetrieverResourcesEvent(AppQueueEvent):
|
|
"""
|
|
QueueRetrieverResourcesEvent entity
|
|
"""
|
|
event = QueueEvent.RETRIEVER_RESOURCES
|
|
retriever_resources: list[dict]
|
|
|
|
|
|
class AnnotationReplyEvent(AppQueueEvent):
|
|
"""
|
|
AnnotationReplyEvent entity
|
|
"""
|
|
event = QueueEvent.ANNOTATION_REPLY
|
|
message_annotation_id: str
|
|
|
|
|
|
class QueueMessageEndEvent(AppQueueEvent):
|
|
"""
|
|
QueueMessageEndEvent entity
|
|
"""
|
|
event = QueueEvent.MESSAGE_END
|
|
llm_result: LLMResult
|
|
|
|
|
|
class QueueAgentThoughtEvent(AppQueueEvent):
|
|
"""
|
|
QueueAgentThoughtEvent entity
|
|
"""
|
|
event = QueueEvent.AGENT_THOUGHT
|
|
agent_thought_id: str
|
|
|
|
|
|
class QueueErrorEvent(AppQueueEvent):
|
|
"""
|
|
QueueErrorEvent entity
|
|
"""
|
|
event = QueueEvent.ERROR
|
|
error: Any
|
|
|
|
|
|
class QueuePingEvent(AppQueueEvent):
|
|
"""
|
|
QueuePingEvent entity
|
|
"""
|
|
event = QueueEvent.PING
|
|
|
|
|
|
class QueueStopEvent(AppQueueEvent):
|
|
"""
|
|
QueueStopEvent entity
|
|
"""
|
|
class StopBy(Enum):
|
|
"""
|
|
Stop by enum
|
|
"""
|
|
USER_MANUAL = "user-manual"
|
|
ANNOTATION_REPLY = "annotation-reply"
|
|
OUTPUT_MODERATION = "output-moderation"
|
|
|
|
event = QueueEvent.STOP
|
|
stopped_by: StopBy
|
|
|
|
|
|
class QueueMessage(BaseModel):
|
|
"""
|
|
QueueMessage entity
|
|
"""
|
|
task_id: str
|
|
message_id: str
|
|
conversation_id: str
|
|
app_mode: str
|
|
event: AppQueueEvent
|