Skip to content

Commit

Permalink
fix(ai-proxy): cohere analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
tysoekong committed Apr 25, 2024
1 parent 45a062a commit ea61c0d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions kong/llm/drivers/cohere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,20 @@ local transformers_from = {
messages.id = response_table.generation_id

local stats = {
completion_tokens = response_table.token_count and response_table.token_count.response_tokens or nil,
prompt_tokens = response_table.token_count and response_table.token_count.prompt_tokens or nil,
total_tokens = response_table.token_count and response_table.token_count.total_tokens or nil,
completion_tokens = response_table.meta
and response_table.meta.billed_units
and response_table.meta.billed_units.output_tokens
or nil,

prompt_tokens = response_table.meta
and response_table.meta.billed_units
and response_table.meta.billed_units.input_tokens
or nil,

total_tokens = response_table.meta
and response_table.meta.billed_units
and (response_table.meta.billed_units.output_tokens + response_table.meta.billed_units.input_tokens)
or nil,
}
messages.usage = stats

Expand Down

0 comments on commit ea61c0d

Please sign in to comment.