mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +00:00
feat: add supports for passing time to dify workflow
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -5,6 +5,7 @@ import json
|
||||
import uuid
|
||||
import re
|
||||
import base64
|
||||
import datetime
|
||||
|
||||
import aiohttp
|
||||
|
||||
@@ -232,15 +233,7 @@ class DifyServiceAPIRunner(runner.RequestRunner):
|
||||
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 = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user