Files
LangBot/plugins/misc/ScheNotify/components/tools/get_current_time_str.py
T

35 lines
1.1 KiB
Python

# Auto generated by LangBot Plugin SDK.
# Please refer to https://langbot.app/docs/en/plugin/dev/tutor.html for more details.
from __future__ import annotations
from typing import Any
import datetime
from langbot_plugin.api.definition.components.tool.tool import Tool
from langbot_plugin.api.entities.builtin.provider import session as provider_session
class GetCurrentTimeStr(Tool):
"""
Get the current time as a string.
This function should be called:
- When the user directly asks for the current time
- Before scheduling any notification to ensure accurate time calculation
"""
async def call(self, params: dict[str, Any], session: provider_session.Session, query_id: int) -> str:
"""
Get current time string in format: %Y-%m-%d %H:%M:%S
Args:
params: Tool parameters (not used)
session: Current session information
query_id: Query ID
Returns:
str: Current time string
"""
# Return current time
current_time = datetime.datetime.now()
return current_time.strftime("%Y-%m-%d %H:%M:%S")