Skip to content

Commit

Permalink
feat: add supports for passing time to dify workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Mar 2, 2025
1 parent 8963a21 commit 92e1ac5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/platform/types/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MessageEvent(Event):
message_chain: platform_message.MessageChain
"""消息内容。"""

time: float
time: float | None = None
"""消息发送时间戳。"""

source_platform_object: typing.Optional[typing.Any] = None
Expand Down
11 changes: 2 additions & 9 deletions pkg/provider/runners/difysvapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import uuid
import re
import base64
import datetime

import aiohttp

Expand Down Expand Up @@ -232,15 +233,7 @@ async def _workflow_messages(
plain_text, image_ids = await self._preprocess_user_message(query)

# 尝试获取 CreateTime
create_time = 0
try:
timestamp = query.message_event.source_platform_object.get('Data', {}).get('CreateTime')
# 确保 timestamp 是整数类型
if isinstance(timestamp, (int, float)):
create_time = int(timestamp)
except AttributeError:
# 如果获取过程中发生属性错误,保持 create_time 为 None
pass
create_time = int(query.message_event.time) if query.message_event.time else int(datetime.datetime.now().timestamp())

files = [
{
Expand Down

0 comments on commit 92e1ac5

Please sign in to comment.