-
Notifications
You must be signed in to change notification settings - Fork 911
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
[Executor] Update openai tokens to trace #1918
[Executor] Update openai tokens to trace #1918
Conversation
SDK CLI Global Config Test Result devs/linatang/update_openai_tokens_to_trace2 tests 2 ✅ 49s ⏱️ Results for commit b6f9c5d. ♻️ This comment has been updated with latest results. |
Executor Unit Test Result devs/linatang/update_openai_tokens_to_trace705 tests 705 ✅ 44s ⏱️ Results for commit b6f9c5d. ♻️ This comment has been updated with latest results. |
promptflow SDK CLI Azure E2E Test Result devs/linatang/update_openai_tokens_to_trace 4 files 4 suites 3m 21s ⏱️ Results for commit b6f9c5d. ♻️ This comment has been updated with latest results. |
Executor E2E Test Result devs/linatang/update_openai_tokens_to_trace187 tests 185 ✅ 3m 48s ⏱️ Results for commit b6f9c5d. ♻️ This comment has been updated with latest results. |
SDK CLI Test Result devs/linatang/update_openai_tokens_to_trace 12 files 12 suites 39m 3s ⏱️ Results for commit b6f9c5d. ♻️ This comment has been updated with latest results. |
f1ec19d
to
2cf8600
Compare
7e3126a
to
8688ac3
Compare
Description
This pull request primarily introduces changes to the
src/promptflow/promptflow/_core/tracer.py
file. The main focus of the changes is to enhance the tracing mechanism by adding aTokenCollector
class for collecting OpenAI tokens associated with spans, and integrating it into the existing tracing flow. The changes also include a minor import modification for the OpenTelemetry library.Main Changes:
src/promptflow/promptflow/_core/tracer.py
: Introduced a new classTokenCollector
to collect OpenAI tokens associated with spans. The class provides methods to collect tokens, merge tokens for parent spans, and retrieve tokens for a given span id.src/promptflow/promptflow/_core/tracer.py
: Theenrich_span_with_output
function now also sets token attributes to the span if any tokens are associated with the span id.src/promptflow/promptflow/_core/tracer.py
: Thewrapped
function (both synchronous and asynchronous versions) now collects OpenAI tokens if the trace type isLLM
, and collects tokens for the parent span before returning the output.All Promptflow Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines