File tree Expand file tree Collapse file tree 3 files changed +30
-25
lines changed
Expand file tree Collapse file tree 3 files changed +30
-25
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - Fix regression: completion broken after rewrite feature API changes.
6+
57## 0.78.0
68
79- Prefix tool name with server to LLM: <server >__ <toolname >. #196
Original file line number Diff line number Diff line change 6060 {:keys [line character]} position
6161 input-code (insert-completion-tag doc-text position)
6262 instructions (f.prompt/inline-completion-prompt config)
63- {:keys [error result]} (deref (future
64- (llm-api/sync-prompt!
65- {:provider provider
66- :model model
67- :config config
68- :prompt input-code
69- :instructions instructions
70- :provider-auth provider-auth
71- :model-capabilities (assoc model-capabilities
72- :reason? false
73- :tools false
74- :web-search false )}))
75- 30000 ; ; TODO move to config
76- {:error {:message " Timeout waiting for completion" }})]
63+ {:keys [error output-text]} (deref (future
64+ (try
65+ (llm-api/sync-prompt!
66+ {:provider provider
67+ :model model
68+ :config config
69+ :prompt input-code
70+ :instructions instructions
71+ :provider-auth provider-auth
72+ :model-capabilities (assoc model-capabilities
73+ :reason? false
74+ :tools false
75+ :web-search false )})
76+ (catch Exception e
77+ {:error {:exception e}})))
78+ 30000 ; ; TODO move to config
79+ {:error {:message " Timeout waiting for completion" }})]
7780 (cond
7881 (:message error)
7982 {:error {:type :warning
8588 {:error {:type :warning
8689 :message (:message (.getMessage ^Exception (:exception error)))}})
8790
88- (not result )
91+ (not output-text )
8992 {:error {:type :info
9093 :message " No suggestions found" }}
9194
9295 :else
93- {:items [{:text (normalize-code-result result )
96+ {:items [{:text (normalize-code-result output-text )
9497 :doc-version doc-version
9598 :range {:start {:line line :character character}
9699 :end {:line line :character character}}}]})))
Original file line number Diff line number Diff line change 2626 json/parse-string)]
2727 (get-in payload [" https://api.openai.com/auth" " chatgpt_account_id" ])))
2828
29+ (defn ^:private response-body->result [body]
30+ {:output-text (reduce
31+ #(str %1 (:text %2 ))
32+ " "
33+ (:content (last (:output body))))})
34+
2935(defn ^:private base-responses-request! [{:keys [rid body api-url auth-type url-relative-path api-key on-error on-stream]}]
3036 (let [oauth? (= :auth/oauth auth-type)
3137 url (if oauth?
3238 codex-url
3339 (str api-url (or url-relative-path responses-path)))
34- response* (atom nil )
3540 on-error (if on-stream
3641 on-error
3742 (fn [error-data]
3843 (llm-util/log-response logger-tag rid " response-error" body)
39- ( reset! response* {:error error-data}) ))]
44+ {:error error-data}))]
4045 (llm-util/log-request logger-tag rid url body)
4146 @(http/post
4247 url
6469 (on-stream event data)))
6570 (do
6671 (llm-util/log-response logger-tag rid " response" body)
67- (reset! response*
68- {:output-text (reduce
69- #(str %1 (:text %2 ))
70- " "
71- (:content (last (:output body))))}))))
72+ (response-body->result body))))
7273 (catch Exception e
7374 (on-error {:exception e}))))
7475 (fn [e]
75- (on-error {:exception e})))
76- @response*))
76+ (on-error {:exception e})))))
7777
7878(defn ^:private normalize-messages [messages supports-image?]
7979 (keep (fn [{:keys [role content] :as msg}]
You can’t perform that action at this time.
0 commit comments