Skip to content

Commit

Permalink
Update src/content/docs/apm/agents/ruby-agent/api-guides/ruby-ai-moni…
Browse files Browse the repository at this point in the history
…toring-apis.mdx

Co-authored-by: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com>
  • Loading branch information
akristen and hannahramadan committed Mar 26, 2024
1 parent 15613b9 commit 291bb49
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -31,14 +31,13 @@ The following example code demonstrates setting a callback that calculates token
require 'tiktoken_ruby' # Example library for counting GPT model tokens used

token_count_callback = proc do |hash|
return unless hash[:model].includes?('gpt')

enc = Tiktoken.encoding_for_model(hash[:model])
enc.encode(hash[:content]).length
return unless hash[:model].includes?('gpt')
enc = Tiktoken.encoding_for_model(hash[:model])
enc.encode(hash[:content]).length
end

NewRelic::Agent.set_llm_token_count_callback(token_count_callback)
```

## User feedback [#user-feedback]

Expand Down

0 comments on commit 291bb49

Please sign in to comment.