Skip to content

Commit

Permalink
show use message while tabnine chat feature not available
Browse files Browse the repository at this point in the history
  • Loading branch information
shuxiao9058 committed Jul 31, 2023
1 parent 7e88eb1 commit 898e5a2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tabnine-chat.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] to join BETA"))

(defun tabnine-chat--context-info(context)
"Get CONTEXT's hash."
(let ((txt (format "%s%s%s" (or (plist-get context :fileCode) "")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 898e5a2

Please sign in to comment.