Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
cfbb7bec
Unverified
Commit
cfbb7bec
authored
Feb 01, 2024
by
Yeuoly
Committed by
GitHub
Feb 01, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat/current time tool zone (#2337)
parent
3b357f51
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
3 deletions
+106
-3
assistant_fc_runner.py
api/core/features/assistant_fc_runner.py
+1
-1
current_time.py
api/core/tools/provider/builtin/time/tools/current_time.py
+11
-2
current_time.yaml
api/core/tools/provider/builtin/time/tools/current_time.yaml
+94
-0
No files found.
api/core/features/assistant_fc_runner.py
View file @
cfbb7bec
...
...
@@ -271,7 +271,7 @@ class AssistantFunctionCallApplicationRunner(BaseAssistantApplicationRunner):
message_file_ids
.
append
(
message_file
.
id
)
except
ToolProviderCredentialValidationError
as
e
:
error_response
=
f
"Plese check your tool provider credentials"
error_response
=
f
"Ple
a
se check your tool provider credentials"
except
(
ToolNotFoundError
,
ToolNotSupportedError
,
ToolProviderNotFoundError
)
as
e
:
...
...
api/core/tools/provider/builtin/time/tools/current_time.py
View file @
cfbb7bec
...
...
@@ -2,6 +2,7 @@ from core.tools.entities.tool_entities import ToolInvokeMessage
from
core.tools.tool.builtin_tool
import
BuiltinTool
from
typing
import
Any
,
Dict
,
List
,
Union
from
pytz
import
timezone
as
pytz_timezone
from
datetime
import
datetime
,
timezone
...
...
@@ -13,5 +14,13 @@ class CurrentTimeTool(BuiltinTool):
"""
invoke tools
"""
# get timezone
tz
=
tool_parameters
.
get
(
'timezone'
,
'UTC'
)
if
tz
==
'UTC'
:
return
self
.
create_text_message
(
f
'{datetime.now(timezone.utc).strftime("
%
Y-
%
m-
%
d
%
H:
%
M:
%
S
%
Z")}'
)
try
:
tz
=
pytz_timezone
(
tz
)
except
:
return
self
.
create_text_message
(
f
'Invalid timezone: {tz}'
)
return
self
.
create_text_message
(
f
'{datetime.now(tz).strftime("
%
Y-
%
m-
%
d
%
H:
%
M:
%
S
%
Z")}'
)
\ No newline at end of file
api/core/tools/provider/builtin/time/tools/current_time.yaml
View file @
cfbb7bec
...
...
@@ -12,3 +12,97 @@ description:
pt_BR
:
A tool for getting the current time.
llm
:
A tool for getting the current time.
parameters
:
-
name
:
timezone
type
:
select
required
:
false
label
:
en_US
:
Timezone
zh_Hans
:
时区
pt_BR
:
Timezone
human_description
:
en_US
:
Timezone
zh_Hans
:
时区
pt_BR
:
Timezone
form
:
form
default
:
UTC
options
:
-
value
:
UTC
label
:
en_US
:
UTC
zh_Hans
:
UTC
pt_BR
:
UTC
-
value
:
America/New_York
label
:
en_US
:
America/New_York
zh_Hans
:
美洲/纽约
pt_BR
:
America/New_York
-
value
:
America/Los_Angeles
label
:
en_US
:
America/Los_Angeles
zh_Hans
:
美洲/洛杉矶
pt_BR
:
America/Los_Angeles
-
value
:
America/Chicago
label
:
en_US
:
America/Chicago
zh_Hans
:
美洲/芝加哥
pt_BR
:
America/Chicago
-
value
:
Asia/Shanghai
label
:
en_US
:
Asia/Shanghai
zh_Hans
:
亚洲/上海
pt_BR
:
Asia/Shanghai
-
value
:
Asia/Tokyo
label
:
en_US
:
Asia/Tokyo
zh_Hans
:
亚洲/东京
pt_BR
:
Asia/Tokyo
-
value
:
Asia/Dubai
label
:
en_US
:
Asia/Dubai
zh_Hans
:
亚洲/迪拜
pt_BR
:
Asia/Dubai
-
value
:
Asia/Kolkata
label
:
en_US
:
Asia/Kolkata
zh_Hans
:
亚洲/加尔各答
pt_BR
:
Asia/Kolkata
-
value
:
Asia/Seoul
label
:
en_US
:
Asia/Seoul
zh_Hans
:
亚洲/首尔
pt_BR
:
Asia/Seoul
-
value
:
Asia/Singapore
label
:
en_US
:
Asia/Singapore
zh_Hans
:
亚洲/新加坡
pt_BR
:
Asia/Singapore
-
value
:
Europe/London
label
:
en_US
:
Europe/London
zh_Hans
:
欧洲/伦敦
pt_BR
:
Europe/London
-
value
:
Europe/Berlin
label
:
en_US
:
Europe/Berlin
zh_Hans
:
欧洲/柏林
pt_BR
:
Europe/Berlin
-
value
:
Europe/Moscow
label
:
en_US
:
Europe/Moscow
zh_Hans
:
欧洲/莫斯科
pt_BR
:
Europe/Moscow
-
value
:
Australia/Sydney
label
:
en_US
:
Australia/Sydney
zh_Hans
:
澳大利亚/悉尼
pt_BR
:
Australia/Sydney
-
value
:
Pacific/Auckland
label
:
en_US
:
Pacific/Auckland
zh_Hans
:
太平洋/奥克兰
pt_BR
:
Pacific/Auckland
-
value
:
Africa/Cairo
label
:
en_US
:
Africa/Cairo
zh_Hans
:
非洲/开罗
pt_BR
:
Africa/Cairo
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment