File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 3030 (testing " throws on uneven kvs"
3131 (is (thrown? IllegalArgumentException
3232 (shared/assoc-some {} :a 1 :b )))))
33+
34+ (deftest tokens->cost-test
35+ (let [db {:models {" my-model" {:input-token-cost 0.01
36+ :output-token-cost 0.02
37+ :input-cache-creation-token-cost 0.005
38+ :input-cache-read-token-cost 0.001 }}}]
39+ (testing " basic input/output cost"
40+ (is (= " 0.70" (shared/tokens->cost 30 nil nil 20 " my-model" db))))
41+ (testing " with cache creation tokens"
42+ (is (= " 0.75" (shared/tokens->cost 30 10 nil 20 " my-model" db))))
43+ (testing " with cache read tokens"
44+ (is (= " 0.73" (shared/tokens->cost 30 nil 30 20 " my-model" db))))
45+ (testing " with both cache creation and read tokens"
46+ (is (= " 0.78" (shared/tokens->cost 30 10 30 20 " my-model" db))))
47+ (testing " accepts provider-prefixed model names"
48+ (is (= " 0.70" (shared/tokens->cost 30 nil nil 20 " provider/my-model" db))))
49+ (testing " returns nil when model is missing from db"
50+ (is (nil? (shared/tokens->cost 30 nil nil 20 " unknown" db))))
51+ (testing " returns nil when mandatory costs are missing"
52+ (is (nil? (shared/tokens->cost 30 nil nil 20 " my-model-missing"
53+ {:models {" my-model-missing" {:input-token-cost 0.01 }}}))))))
You can’t perform that action at this time.
0 commit comments