File tree Expand file tree Collapse file tree 6 files changed +49
-32
lines changed
Expand file tree Collapse file tree 6 files changed +49
-32
lines changed Original file line number Diff line number Diff line change 33## Unreleased
44
55- Fix Gemini (OpenAI compatible). #247
6+ - Improve login wording + add cancel option. #205
67
78## 0.91.2
89
Original file line number Diff line number Diff line change 254254 :content (merge {:type :usage }
255255 usage)})))
256256 :prompt (f.prompt/compact-prompt (string/join " " args) all-tools config db)})
257- " login" (do (f.login/handle-step {:message (or (first args) " " )
258- :chat-id chat-id}
259- db*
260- messenger
261- config
262- metrics)
263- {:type :new-chat-status
264- :status :login })
257+ " login" (do
258+ (messenger/chat-content-received
259+ messenger
260+ {:chat-id chat-id
261+ :role " system"
262+ :content {:type :text
263+ :text " Login started, type 'cancel' anytime to exit login." }})
264+ (f.login/handle-step {:message (or (first args) " " )
265+ :chat-id chat-id}
266+ db*
267+ messenger
268+ config
269+ metrics)
270+ {:type :new-chat-status
271+ :status :login })
265272 " resume" (let [chats (into {}
266273 (filter #(not= chat-id (first %)))
267274 (:chats db))
Original file line number Diff line number Diff line change 2222 (send-msg! (reduce
2323 (fn [s provider]
2424 (str s " - " provider " \n " ))
25- " Choose a provider:\n "
25+ " Inform the provider:\n \n"
2626 providers)))))
2727
2828(defn handle-step [{:keys [message chat-id]} db* messenger config metrics]
2929 (let [provider (get-in @db* [:chats chat-id :login-provider ])
3030 step (get-in @db* [:auth provider :step ] :login/start )
3131 input (string/trim message)
32+ send-msg! (fn [msg]
33+ (messenger/chat-content-received
34+ messenger
35+ {:chat-id chat-id
36+ :role " system"
37+ :content {:type :text
38+ :text msg}})
39+ (messenger/chat-content-received
40+ messenger
41+ {:chat-id chat-id
42+ :role " system"
43+ :content {:type :progress
44+ :state :finished }}))
3245 ctx {:chat-id chat-id
3346 :step step
3447 :input input
3750 :messenger messenger
3851 :metrics metrics
3952 :provider provider
40- :send-msg! (fn [msg]
41- (messenger/chat-content-received
42- messenger
43- {:chat-id chat-id
44- :role " system"
45- :content {:type :text
46- :text msg}})
47- (messenger/chat-content-received
48- messenger
49- {:chat-id chat-id
50- :role " system"
51- :content {:type :progress
52- :state :finished }}))}]
53+ :send-msg! send-msg!}]
5354 (messenger/chat-content-received
5455 messenger
5556 {:chat-id chat-id
5657 :role " user"
5758 :content {:type :text
5859 :text (str input " \n " )}})
59- (login-step ctx)
60- {:chat-id chat-id
61- :status :login }))
60+ (if (= " cancel" input)
61+ (do
62+ (send-msg! " Login cancelled" )
63+ (swap! db* assoc-in [:chats chat-id :login-provider ] nil )
64+ (swap! db* assoc-in [:chats chat-id :status ] :idle )
65+ {:chat-id chat-id
66+ :status :idle })
67+ (do
68+ (login-step ctx)
69+ {:chat-id chat-id
70+ :status :login }))))
6271
6372(defn ^:private renew-auth!
6473 [provider
Original file line number Diff line number Diff line change 363363 (swap! db* assoc-in [:auth provider] {:step :login/waiting-login-method })
364364 (send-msg! (multi-str " Now, inform the login method:"
365365 " "
366- " max: Claude Pro/Max"
367- " console: Create API Key"
368- " manual: Manually enter API Key" )))
366+ " - max: Claude Pro/Max"
367+ " - console: Automatically create API Key and use it "
368+ " - manual: Manually enter API Key" )))
369369
370370(defmethod f.login /login-step [" anthropic" :login/waiting-login-method ] [{:keys [db* input provider send-msg!]}]
371371 (case input
Original file line number Diff line number Diff line change 337337 (swap! db* assoc-in [:auth provider] {:step :login/waiting-login-method })
338338 (send-msg! (multi-str " Now, inform the login method:"
339339 " "
340- " pro: GPT Plus/Pro (subscription)"
341- " manual: Manually enter API Key" )))
340+ " - pro: GPT Plus/Pro (subscription)"
341+ " - manual: Manually enter API Key" )))
342342
343343(defmethod f.login /login-step [" openai" :login/waiting-login-method ] [{:keys [db* input provider send-msg!] :as ctx}]
344344 (case input
Original file line number Diff line number Diff line change 2222 :send-msg! send-msg!})
2323
2424 (testing " should ask to choose a provider"
25- (is (= " Choose a provider:\n - github-copilot\n - google\n "
25+ (is (= " Inform the provider:\n \n - github-copilot\n - google\n "
2626 (last @msg-log)))))
2727
2828 (testing " user is confused"
3434 :send-msg! send-msg!})
3535
3636 (testing " should ask to choose a provider and provide instructions"
37- (is (= " Choose a provider:\n - github-copilot\n - google\n "
37+ (is (= " Inform the provider:\n \n - github-copilot\n - google\n "
3838 (last @msg-log)))
3939
4040 (testing " state didn't change"
You can’t perform that action at this time.
0 commit comments