nsmcp::QuestionService method event (public)

 <instance of nsmcp::QuestionService[i]> event handle turn event

Defined in /usr/local/ns/tcl/nsmcp/question-service.tcl

Parameters:
handle (required)
turn (required)
event (required)

Testcases:
No testcase defined.
Source code:
ns_mutex lock ${:mutex}
try {
    if {![nsv_exists ${:store} $handle]} {return false}
    set record [nsv_get ${:store} $handle]
    if {[dict get $record current] ne $turn} {return false}
    set continue [expr {[dict get $record status] ne "cancelling"}]
    if {[dict get $event type] eq "check"} {return $continue}
    set last [lindex [dict get $record turns] end]
    switch -- [dict get $event type] {
        text {dict append last answer [dict get $event text]}
        job {
            set key [dict get $event jobHandle]
            if {![dict exists $last jobs $key] && [dict exists $last jobs] && [dict size [dict get $last jobs]]>=128} {
                error "Question background job limit reached"
            }
            dict set last jobs $key $event
        }
        tool {dict lappend last tools [:toolEvidence $handle $event]}
        state {
            set state [dict get $event state]
            if {[string bytelength $state]>${:maxBytes}} {error "Question continuation size limit reached; start a new conversation"}
            dict set record state [zlib compress [encoding convertto utf-8 $state]]
            dict set record stateEncoding zlib-tcl-v1
        }
    }
    dict set record turns [lreplace [dict get $record turns] end end $last]
    if {[string bytelength $record] > ${:maxBytes}} {error "Conversation size limit reached (${:maxBytes} bytes); start a new conversation"}
    nsv_set ${:store} $handle $record
    return $continue
} finally {ns_mutex unlock ${:mutex}}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: