gptel-anthropic: Simplify stream parser
* gptel-anthropic.el (gptel-curl--parse-stream): Remove extraneous statements and simplify the stream parser. Addresses #261, but the main problem is still elusive.
This commit is contained in:
parent
22f7043c32
commit
5d069cfca8
1 changed files with 6 additions and 8 deletions
|
@ -45,14 +45,12 @@
|
||||||
(condition-case nil
|
(condition-case nil
|
||||||
(while (re-search-forward "^event: " nil t)
|
(while (re-search-forward "^event: " nil t)
|
||||||
(setq pt (match-beginning 0))
|
(setq pt (match-beginning 0))
|
||||||
(cond
|
(when (looking-at "content_block_\\(?:start\\|delta\\|stop\\)")
|
||||||
((looking-at "content_block_\\(?:start\\|delta\\|stop\\)")
|
(forward-line 1) (forward-char 5)
|
||||||
(save-match-data
|
(when-let* ((response (gptel--json-read))
|
||||||
(forward-line 1) (forward-char 5)
|
(content (map-nested-elt
|
||||||
(when-let* ((response (gptel--json-read))
|
response '(:delta :text))))
|
||||||
(content (map-nested-elt
|
(push content content-strs))))
|
||||||
response '(:delta :text))))
|
|
||||||
(push content content-strs))))))
|
|
||||||
(error (goto-char pt)))
|
(error (goto-char pt)))
|
||||||
(apply #'concat (nreverse content-strs))))
|
(apply #'concat (nreverse content-strs))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue