-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create token_count
attribute
#2489
Create token_count
attribute
#2489
Conversation
This attribute is available on ChatCompletionMessage and Embedding
@@ -101,8 +102,7 @@ def create_chat_completion_messages(parameters, summary_id) | |||
role: message[:role] || message['role'], | |||
sequence: index, | |||
completion_id: summary_id, | |||
vendor: VENDOR, | |||
is_response: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unrelated fix. This first group of messages are not from a response. They're from a request. The is_response
should only be attached to the event if it has a truthy value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
end | ||
end | ||
|
||
def calculate_token_count(model, content) | ||
# return unless NewRelic::Agent.config['ai_monitoring.record_content.enabled'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This'll get uncommented once the config PR is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good after the completion_id stuff is added back ◡̈
SimpleCov Report
|
token_count
toChatCompletionMessage
andEmbedding
token_count
using the customer-provided callback set byset_llm_token_count_callback
and assigns it in OpenAI instrumentationtoken_count
attribute.Closes #2450