-
Notifications
You must be signed in to change notification settings - Fork 342
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
metrics: add debug capabilities #260
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tanzimCohere
had a problem deploying
to
development
June 21, 2024 14:15
— with
GitHub Actions
Failure
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #260 +/- ##
=======================================
Coverage ? 86.66%
=======================================
Files ? 149
Lines ? 5549
Branches ? 0
=======================================
Hits ? 4809
Misses ? 740
Partials ? 0 ☔ View full report in Codecov by Sentry. |
tanzimCohere
requested review from
EugeneLightsOn,
malexw,
scottmx81,
tianjing-li and
a team
as code owners
June 21, 2024 16:13
scott-cohere
approved these changes
Jun 21, 2024
tanzimCohere
force-pushed
the
debug-metrics
branch
from
June 21, 2024 20:00
be98013
to
daa101b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for contributing to the Cohere Toolkit!
PR title: "area: description"
PR message: Delete this entire checklist and replace with
Add tests and docs: Please include testing and documentation for your changes
Lint and test: Run
make lint
andmake run-tests
AI Description
This PR introduces a new helper script,
metrics_helper.py
, which contains functions for interacting with the Cohere Platform's user, agent, and conversation management endpoints. It also includes updates to the backend code related to user and agent management, and modifications to the metrics middleware and reporting functionality.helper_scripts/metrics_helper.py
A new helper script has been added, which provides functions for creating, updating, listing, and deleting users and agents, as well as initiating a chat session and performing related operations.
src/backend/routers/agent.py
andsrc/backend/routers/user.py
The
update_agent
andupdate_user
functions have been modified to include the linerequest.state.agent = agent
andrequest.state.user = UserSchema.model_validate(db_user)
, respectively. This ensures that the request state is updated with the modified agent or user details.The
delete_agent
anddelete_user
functions have also been updated to include the linerequest.state.agent = agent
andrequest.state.user = UserSchema.model_validate(user)
, respectively, to capture the state before deletion.src/backend/schemas/metrics.py
A new class
MetricsSignal
has been added, which contains asignal
attribute of typeMetricsData
.src/backend/services/metrics.py
The
dispatch
function signature has been updated to include thecall_next
parameter ascall_next: Callable
.The
get_data
function has been renamed toget_event_data
, and it now returns a value of typeMetricsData
.The
get_user_id
function now includes a return type annotation,Union [str, None]
.The
report_metrics
function has been updated to accept aMetricsSignal
object as an argument and includes additional error handling for cases where the signal is not a dictionary.Two new functions,
wrap_and_log_data
andrun_loop
, have been added to handle the logging and reporting of metrics data.The
run_loop
function has been moved from its previous location within theMetricsMiddleware
class to the module's global scope.The
report_metrics
function is now asynchronous, and therun_loop
function has been updated to use it accordingly.