File tree Expand file tree Collapse file tree
test/yetibot/core/test/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change 132132(defn say-final
133133 " The clean final reply: Gemini's summary plus links to any relevant PRs."
134134 [summary pr-urls]
135- (str (if (string/blank? summary) " ✅ done." (str " ✅ " summary))
136- (when (seq pr-urls)
137- (str " \n\n 🔗 " (string/join " • " (distinct pr-urls))))))
135+ (let [footer (format " \n\n Sent via %s | Cost: $%.2f" (model ) (gemini/agent-cost-per-session ))]
136+ (str (if (string/blank? summary) " ✅ done." (str " ✅ " summary))
137+ (when (seq pr-urls)
138+ (str " \n\n 🔗 " (string/join " • " (distinct pr-urls))))
139+ footer)))
138140
139141(defn say-broken [msg]
140142 (str " ⚠️ Gemini error: " msg))
Original file line number Diff line number Diff line change 3535 (str " Generate an image: " prompt) nil image-urls)
3636 id (store-image! image)
3737 base-url (gemini/yetibot-base-url )
38- image-url (format " %s/generated-images/%s.png" base-url id)]
38+ image-url (format " %s/generated-images/%s.png" base-url id)
39+ footer (format " \n\n Sent via %s | Cost: $%.3f" (gemini/gemini-model ) (gemini/cost-per-image ))]
3940 (info " banana: image generated successfully, serving at" image-url)
40- {:result/value image-url
41+ {:result/value ( str image-url footer)
4142 :result/data {:id id :prompt match :url image-url}})
4243 (catch Exception e
4344 (error " banana: Gemini image generation error:" (.getMessage e))
Original file line number Diff line number Diff line change 5555 " Default monthly budget in USD for image generation."
5656 5.00 )
5757
58- (defn- cost-per-image []
58+ (defn cost-per-image []
5959 (or (parse-number (-> config :cost :per ))
6060 (case (gemini-model )
6161 " gemini-3.1-flash-image-preview" 0.039
6868(defn- max-images-per-month []
6969 (long (Math/floor (/ (monthly-budget ) (cost-per-image )))))
7070
71- (defn- agent-cost-per-session []
71+ (defn agent-cost-per-session []
7272 (or (parse-number (-> config :agent :cost-per-session )) 1.00 ))
7373
7474(defn agent-cost-units []
Original file line number Diff line number Diff line change 7373 (agent/say-final " done" [" https://github.com/yetibot/core/pull/242" ]) => (contains " pull/242" ))
7474 (fact " say-final copes with a blank answer"
7575 (agent/say-final " " nil ) => (contains " done" ))
76+ (fact " say-final appends the model and cost footer"
77+ (agent/say-final " Added features" nil ) => (contains " Sent via gemini-3.1-pro-preview | Cost: $1.00" ))
7678 (fact " say-timeout names the limit"
7779 (agent/say-timeout 5 ) => (contains " 5 min" )))
7880
Original file line number Diff line number Diff line change 2323 :agent-sessions-left 10
2424 :agent-cost-units 10
2525 :month " 2026-05" })))
26+
27+ (facts " about banana-cmd"
28+ (fact " it generates an image and returns URL with model and cost footer"
29+ (b/banana-cmd {:match " banana monkey" :chat-source {}})
30+ => (contains {:result/value #"http://localhost:3003/generated-images/img123.png\n\n Sent via gemini-3.1-flash-image-preview \| Cost: \$ 0.039"
31+ :result/data {:id " img123" :prompt " banana monkey" :url " http://localhost:3003/generated-images/img123.png" }})
32+ (provided
33+ (gemini/configured? ) => true
34+ (yetibot.core.util.image-input/extract-images " banana monkey" {}) => {:prompt " monkey" :image-urls []}
35+ (gemini/generate-image " Generate an image: monkey" nil []) => {:data " bytes" :mime-type " image/png" }
36+ (yetibot.core.webapp.routes.images/store-image! {:data " bytes" :mime-type " image/png" }) => " img123"
37+ (gemini/yetibot-base-url ) => " http://localhost:3003"
38+ (gemini/gemini-model ) => " gemini-3.1-flash-image-preview"
39+ (gemini/cost-per-image ) => 0.039 )))
You can’t perform that action at this time.
0 commit comments