-
Notifications
You must be signed in to change notification settings - Fork 693
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
fix(anthropic): add instrumentation for Anthropic tool calling (alternative to #1372) #2150
Conversation
This commit addresses [traceloop#879] by implementing instrumentation of Anthropic tools request args and tool_use response arguments
if content_block_type == "text": | ||
text += content.text |
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.
@nirga looking for your input on this. I tried to stay as close to OpenAI as possible. For OpenAI the index
, is the ordinal number of the output in the choices
array. I believe, there is no such thing in Anthropic, so index
is always 0.
In theory, Anthropic could respond with something like [text, tool_use, text, text, tool_use]
. I've never seen it do this in practice, but just in case, instead of hard-coding, I decided to concatenate everything in the text block.
An alternative to my approach would be to set these text
blocks as gen_ai.completions.i.content
, but I don't think this is consistent with the choices
in OpenAI.
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.
Makes sense @dinmukhamedm! Long term we plan to move these to otel events so there will be a "cleaner" solution
Sorry about the back and forth, had some trouble running |
This commit addresses [#879] by implementing instrumentation of Anthropic
tools
request args andtool_use
response arguments.feat(instrumentation): ...
orfix(instrumentation): ...
.