构建mars_toolkit,删除tools_for_ms
This commit is contained in:
29
mars_toolkit/misc/misc_tools.py
Normal file
29
mars_toolkit/misc/misc_tools.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
General Tools Module
|
||||
|
||||
This module provides basic utility functions that are not specific to materials science.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
from typing import Annotated
|
||||
|
||||
from mars_toolkit.core.llm_tools import llm_tool
|
||||
|
||||
@llm_tool(name="get_current_time", description="Get current date and time in specified timezone")
|
||||
async def get_current_time(timezone: str = "UTC") -> str:
|
||||
"""Returns the current date and time in the specified timezone.
|
||||
|
||||
Args:
|
||||
timezone: Timezone name (e.g., UTC, Asia/Shanghai, America/New_York)
|
||||
|
||||
Returns:
|
||||
Formatted date and time string
|
||||
"""
|
||||
try:
|
||||
tz = pytz.timezone(timezone)
|
||||
current_time = datetime.now(tz)
|
||||
return f"The current {timezone} time is: {current_time.strftime('%Y-%m-%d %H:%M:%S %Z')}"
|
||||
except pytz.exceptions.UnknownTimeZoneError:
|
||||
return f"Unknown timezone: {timezone}. Please use a valid timezone such as 'UTC', 'Asia/Shanghai', etc."
|
||||
Reference in New Issue
Block a user