Skip to content

Commit

Permalink
Add datetime provider
Browse files Browse the repository at this point in the history
Signed-off-by: Di Wang <[email protected]>
  • Loading branch information
hemslo committed Feb 16, 2024
1 parent e27048c commit 0ab48e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from app.chains.supervisor import build_supervisor_chain
from app.dependencies.openai_chat_model import openai_chat_model
from app.tools.datetime_provider import datetime_provider
from app.tools.random_number import random_number
from app.tools.random_select import random_select
from app.tools.webrca_create import webrca_create
Expand Down Expand Up @@ -70,6 +71,10 @@ class AgentState(TypedDict):
"SlackSearcher": {
"tools": [slack_searcher],
"system_prompt": "You are a slack searcher.",
},
"DatetimeProvider": {
"tools": [datetime_provider],
"system_prompt": "You are a datetime provider.",
}
}

Expand Down
16 changes: 16 additions & 0 deletions app/tools/datetime_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import datetime
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError

from langchain_core.tools import tool


@tool()
def datetime_provider(iana_timezone: str = "UTC") -> str:
"""
Get the current date time in ISO 8601 format for the given IANA timezone
"""
try:
zone = ZoneInfo(iana_timezone)
except ZoneInfoNotFoundError:
zone = datetime.UTC
return datetime.datetime.now(zone).isoformat()

0 comments on commit 0ab48e4

Please sign in to comment.