-
Notifications
You must be signed in to change notification settings - Fork 868
fix(openai): Support report token usage in stream mode #661
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
Conversation
…to stream_token # Conflicts: # packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py # packages/opentelemetry-instrumentation-openai/poetry.lock # packages/opentelemetry-instrumentation-openai/pyproject.toml # packages/opentelemetry-instrumentation-openai/tests/metrics/test_openai_metrics.py # packages/opentelemetry-instrumentation-openai/tests/traces/test_chat.py # packages/opentelemetry-instrumentation-openai/tests/traces/test_completions.py
|
CI error: tiktoken need to download file at it first run, so vcr's none record mode maybe not suite for it... @nirga Do u have some thoughts about it? |
|
@Humbertzhang you can tell VCR to ignore certain hostnames, then it will not try and replay the cassette for those host names, but actually try to make an HTTP call, see this example -
|
| return model | ||
|
|
||
|
|
||
| def should_record_stream_token_usage(): |
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.
Let's put it as an optional parameter to the __init__ of the instrumentation (I'd default it to true)? I think it's cleaner (and I want to move the should_trace_content to be like that as well)
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.
You mean move it to Traceloop.init()'s arg, right?
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.
No, the instrumentation init. Then traceloop sdk can pass it yes
…to stream_token # Conflicts: # packages/opentelemetry-instrumentation-langchain/poetry.lock # packages/opentelemetry-instrumentation-llamaindex/poetry.lock # packages/opentelemetry-instrumentation-openai/poetry.lock # packages/opentelemetry-instrumentation-pinecone/poetry.lock # packages/opentelemetry-instrumentation-weaviate/poetry.lock
|
Hello @nirga, I have resolved the VCR issue by adding ignore_hosts. However, I'm not entirely sure what you mean by Could you provide me an example? Alternatively, we could just merge this, and I can make modifications in a later PR after you've updated |
|
@Humbertzhang sure, thanks! |
Fixes #627
feat(instrumentation): ...orfix(instrumentation): ....Related doc PR: Update docs for TRACELOOP_STREAM_TOKEN_USAGE docs#24