Summary
fastllm's cost tracking crashes for model not present in the bundled
model_prices.json . Only a small hand-picked subset of Ollama tags
are keys in that file — e.g. ollama/llama2 is present, but ministral-3:3b
(and many other locally-pulled models) isn't.
Repro
ssage --vendor_name openai_chat --base_url http://localhost:11434/v1
--api_key ollama --model ministral-3:3b "hi"
The completion succeeds, but crashes right after while tracking usage:
File ".../fastllm/openai_chat.py", line 204, in cost
cost = in_txt * m.input_cost_per_token + out_txt * m.output_cost_per_token
AttributeError: input_cost_per_token
Cause
cost() looks up the model name in model_prices.json and assumes the
result always has input_cost_per_token/output_cost_per_token. There's as far as I can see no
fallback for models that aren't a key in that file.
Suggested fix
Default to cost = 0 when a model isn't found, rather than raising. Probably
also add a wildcard fallback for ollama models generally.
Summary
fastllm's cost tracking crashes for model not present in the bundledmodel_prices.json. Only a small hand-picked subset of Ollama tagsare keys in that file — e.g.
ollama/llama2is present, butministral-3:3b(and many other locally-pulled models) isn't.
Repro
ssage --vendor_name openai_chat --base_url http://localhost:11434/v1
--api_key ollama --model ministral-3:3b "hi"
The completion succeeds, but crashes right after while tracking usage:
File ".../fastllm/openai_chat.py", line 204, in cost
cost = in_txt * m.input_cost_per_token + out_txt * m.output_cost_per_token
AttributeError: input_cost_per_token
Cause
cost()looks up the model name inmodel_prices.jsonand assumes theresult always has
input_cost_per_token/output_cost_per_token. There's as far as I can see nofallback for models that aren't a key in that file.
Suggested fix
Default to
cost = 0when a model isn't found, rather than raising. Probablyalso add a wildcard fallback for ollama models generally.