Skip to content

Commit

Permalink
Add support for switchable models #12
Browse files Browse the repository at this point in the history
  • Loading branch information
shuxiao9058 committed Nov 12, 2024
1 parent 64b1556 commit b2364ee
Show file tree
Hide file tree
Showing 3 changed files with 308 additions and 64 deletions.
19 changes: 9 additions & 10 deletions tabnine-chat-curl.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,19 @@
"Produce list of arguments for calling Curl.
INFO is the chat info to send, TOKEN is a unique identifier.."
(let* ((request (tabnine-chat--make-request info))
(data (tabnine-util--json-serialize request))
(url (format "%s/chat/v3/generate_chat_response" tabnine-api-server))
(let* ((stream-id (plist-get info :stream-id))
(url (format "%s/chat/v1/stream/%s/wait" tabnine-api-server stream-id))
(headers
`(("Content-Type" . "application/json; charset=utf-8")
("Authorization" . ,(concat "Bearer " (tabnine--access-token))))))
`(("Authorization" . ,(concat "Bearer " (tabnine--access-token))))))
(append
(list "--location" "--silent" "--compressed" "--disable"
(format "-X%s" "POST")
(format "-X%s" "GET")
(format "-w(%s . %%{size_header})" token)
(format "-m%s" 60)
"-D-"
(format "-d%s" data))
"-D-")
(when (and tabnine-network-proxy (stringp tabnine-network-proxy)
(not (string-empty-p tabnine-network-proxy)))
(list "--proxy" tabnine-network-proxy))
(list "--insecure" "--proxy" tabnine-network-proxy))
(cl-loop for (key . val) in headers
collect (format "-H%s: %s" key val))
(list url))))
Expand Down Expand Up @@ -245,7 +242,9 @@ PROCESS is the process under watch, OUTPUT is the output received."
(end-of-line) (point)))
'utf-8))
(response (tabnine-util--read-json (s-trim line-content)))
(content (plist-get response :text)))
(content (or (when-let* ((value (plist-get response :value))
(text (plist-get value :text)))
text) "")))
(push content content-strs))
(forward-line))
(error
Expand Down
Loading

0 comments on commit b2364ee

Please sign in to comment.