diff --git a/literate/reason.org b/literate/reason.org index 36cb437..9420573 100644 --- a/literate/reason.org +++ b/literate/reason.org @@ -66,7 +66,11 @@ The Reason stage is the cognitive engine of the OpenCortex. It bridges the gap b (cleaned (if (stringp thought) (string-trim '(#\Space #\Newline #\Tab) thought) thought))) (if (stringp cleaned) (let ((*read-eval* nil)) - (handler-case (read-from-string cleaned) + (handler-case + (let ((parsed (read-from-string cleaned))) + (if (and (listp parsed) (getf parsed :response)) + (list :TYPE :CHAT :TEXT (getf parsed :response)) + parsed)) (error (c) (list :type :EVENT :payload (list :sensor :syntax-error :code cleaned :error (format nil "~a" c)))))) cleaned))))) #+end_src diff --git a/src/reason.lisp b/src/reason.lisp index cdec672..0048f7c 100644 --- a/src/reason.lisp +++ b/src/reason.lisp @@ -44,7 +44,11 @@ (cleaned (if (stringp thought) (string-trim '(#\Space #\Newline #\Tab) thought) thought))) (if (stringp cleaned) (let ((*read-eval* nil)) - (handler-case (read-from-string cleaned) + (handler-case + (let ((parsed (read-from-string cleaned))) + (if (and (listp parsed) (getf parsed :response)) + (list :TYPE :CHAT :TEXT (getf parsed :response)) + parsed)) (error (c) (list :type :EVENT :payload (list :sensor :syntax-error :code cleaned :error (format nil "~a" c)))))) cleaned)))))