mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-10 06:18:59 +08:00
feat: optimize current time (#661)
This commit is contained in:
parent
eae670ea4a
commit
d979955c8a
@ -27,13 +27,13 @@ from core.orchestrator_rule_parser import OrchestratorRuleParser
|
|||||||
from core.prompt.prompt_builder import PromptBuilder
|
from core.prompt.prompt_builder import PromptBuilder
|
||||||
from core.prompt.prompt_template import JinjaPromptTemplate
|
from core.prompt.prompt_template import JinjaPromptTemplate
|
||||||
from core.prompt.prompts import MORE_LIKE_THIS_GENERATE_PROMPT
|
from core.prompt.prompts import MORE_LIKE_THIS_GENERATE_PROMPT
|
||||||
from models.model import App, AppModelConfig, Account, Conversation, Message
|
from models.model import App, AppModelConfig, Account, Conversation, Message, EndUser
|
||||||
|
|
||||||
|
|
||||||
class Completion:
|
class Completion:
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls, task_id: str, app: App, app_model_config: AppModelConfig, query: str, inputs: dict,
|
def generate(cls, task_id: str, app: App, app_model_config: AppModelConfig, query: str, inputs: dict,
|
||||||
user: Account, conversation: Optional[Conversation], streaming: bool, is_override: bool = False):
|
user: Union[Account, EndUser], conversation: Optional[Conversation], streaming: bool, is_override: bool = False):
|
||||||
"""
|
"""
|
||||||
errors: ProviderTokenNotInitError
|
errors: ProviderTokenNotInitError
|
||||||
"""
|
"""
|
||||||
|
@ -250,7 +250,8 @@ class OrchestratorRuleParser:
|
|||||||
def to_current_datetime_tool(self) -> Optional[BaseTool]:
|
def to_current_datetime_tool(self) -> Optional[BaseTool]:
|
||||||
tool = Tool(
|
tool = Tool(
|
||||||
name="current_datetime",
|
name="current_datetime",
|
||||||
description="A tool when you want to get the current date or time. ",
|
description="A tool when you want to get the current date, time, week, month or year, "
|
||||||
|
"and the time zone is UTC. Result is \"<date> <time> <timezone> <week>\".",
|
||||||
func=helper.get_current_datetime,
|
func=helper.get_current_datetime,
|
||||||
callbacks=[DifyStdOutCallbackHandler()]
|
callbacks=[DifyStdOutCallbackHandler()]
|
||||||
)
|
)
|
||||||
|
@ -158,4 +158,4 @@ def generate_text_hash(text: str) -> str:
|
|||||||
def get_current_datetime(type: str) -> str:
|
def get_current_datetime(type: str) -> str:
|
||||||
# get current time
|
# get current time
|
||||||
current_time = datetime.utcnow()
|
current_time = datetime.utcnow()
|
||||||
return current_time.strftime("%Y-%m-%d %H:%M:%S %Z%z")
|
return current_time.strftime("%Y-%m-%d %H:%M:%S UTC+0000 %A")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user