GetDateInterval
This action is designed to determine the time interval between two datetime.
GetDateInterval(
dateFrom: str,
dateTo: str,
unit: Literal[
"second",
"minute",
"hour",
"day",
"month",
"year",
] = "second"
)
Where:
- dateFrom: date and time of the beginning of the interval;
- dateTo: date and time of the end of the interval;
- unit: result unit.
Example (Measuring Generation Time)
The below example takes the time before and after the LLM response and uses the GetDateInterval action to get the generation time in seconds.
{{#system~}}
{{#block(hidden=True)}}
{{set(name="agent", value=GetAgent())}}
{{set(name="memory", value=GetMemory(count=40, maxLen=20000))}}
{{/block}}
{{set(name='start_gen_datetime', value=GetDatetime(format= "datetime"))}}
{{memory}}
{{agent}}:{{~/system}}{{#assistant~}}{{gen(name="RESULT", temperature=0.7)}}{{~/assistant}}{{#system~}}
{{set(name='end_gen_datetime', value=GetDatetime(format= "datetime"))}}
{{set(name='gen_time', value=GetDateInterval(
dateFrom=start_gen_datetime,
dateTo=end_gen_datetime,
unit="second"
))}}
{{SendMessage(message=gen_time)}}
{{~/system}}
Updated 9 months ago