From 898e5a2983c26be40e3209d75fda27e810752d85 Mon Sep 17 00:00:00 2001 From: Aaron Ji Date: Mon, 31 Jul 2023 22:26:10 +0800 Subject: [PATCH] show use message while tabnine chat feature not available --- tabnine-chat.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tabnine-chat.el b/tabnine-chat.el index dbbb8cf..2926102 100644 --- a/tabnine-chat.el +++ b/tabnine-chat.el @@ -209,6 +209,10 @@ use for TabNine Chat." (setq tabnine-chat--conversation-id (tabnine-util--random-uuid))) tabnine-chat--conversation-id) +(defun tabnine-chat--error-no-chat-feature () + "Signal user error while TabNine Chat feature not available." + (user-error "TabNine Chat feature is NOT available yet, please send Tabnine Pro email to support@tabnine.com to join BETA")) + (defun tabnine-chat--context-info(context) "Get CONTEXT's hash." (let ((txt (format "%s%s%s" (or (plist-get context :fileCode) "") @@ -463,6 +467,10 @@ prompt and the response. STREAM is a boolean that determines if the response should be streamed, as in `tabnine-chat-stream'. Do not set this if you are specifying a custom CALLBACK!" + (unless tabnine--chat-enabled + (tabnine-capabilities)) + (unless tabnine--chat-enabled + (tabnine-chat--error-no-chat-feature)) (let* ((tabnine-chat-stream stream) (start-marker (cond @@ -586,6 +594,8 @@ Return body, http-status, http-msg and error in list." (t (list nil http-status http-msg (concat "Unknown error: " trim-body)))))) ((equal http-status "404");; token expired (message "TabNine token is expired, set tabnine--access-token to nil.") + (unless tabnine--chat-enabled + (tabnine-chat--error-no-chat-feature)) (setq tabnine--access-token nil) (list nil http-status http-msg "TabNine token expired")) (t (unless (progn (goto-char (point-min))