Demonstrations
What Time Is It?
Give your Voqal Assistant the powers of a clock
As of now, Voqal cannot tell you the current time. However, this ability is easy to implement and provides a great example of how to customize Voqal for real-time information and private data.
Directive
what time is it
Demonstration
Implementation
Option 1: Context Extension
The embedded computer context extension has the ability to provide the current time.
To print the current time in a prompt template, use the following code:
{{ computer.currentTime | date("yyyy-MM-dd'T'HH:mm:ssX") }}
See https://pebbletemplates.io/wiki/filter/date/ for more information on the date
filter.
Option 2: Custom Prompt URL
fun main() {
embeddedServer(Netty, port = 8080) {
routing {
get("/time-aware-voqal") {
//download idle mode prompt
val idleModeText = URL("https://voqal.dev/prompts/embedded/voqal-idle-mode.md").readText()
//create prompt containing current time
val timePrompt = buildString {
appendLine("## System Information")
appendLine()
appendLine("Current time is: ${Instant.now()}")
appendLine("Current timezone is: ${System.getProperty("user.timezone")}")
appendLine()
}
//insert system information before `## System Mode` section
val systemModeIndex = idleModeText.indexOf("## System Mode")
val timeAwarePrompt = idleModeText.substring(0, systemModeIndex) +
timePrompt + idleModeText.substring(systemModeIndex)
//return updated prompt
call.respondText(timeAwarePrompt)
}
}
}.start(wait = true)
}
Example Response
## Assistant Tool Request
### answer_question
```json
{
"answer": "The current time is 19:51 and the timezone is GMT-05:00."
}
```