Skip to content

Commit

Permalink
fix(ai-proxy): another null check
Browse files Browse the repository at this point in the history
  • Loading branch information
tysoekong committed Apr 25, 2024
1 parent 35c0f95 commit 5d19ded
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kong/llm/drivers/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function _M.calculate_cost(query_body, tokens_models, tokens_factor)
if query_body.choices then
-- Calculate the cost based on the content type
for _, choice in ipairs(query_body.choices) do
if choice.message.content then
if choice.message and choice.message.content then
query_cost = query_cost + (count_words(choice.message.content) * tokens_factor)
elseif choice.text then
query_cost = query_cost + (count_words(choice.text) * tokens_factor)
Expand Down

0 comments on commit 5d19ded

Please sign in to comment.