Conversation
Co-authored-by: dhuang <dhuang@fireworks.ai>
|
Cursor Agent can help with this pull request. Just |
eval_protocol/reward_function.py
Outdated
| headers = { | ||
| "Content-Type": "application/json", | ||
| "Authorization": f"Bearer {api_key}" if api_key else "", | ||
| "User-Agent": get_user_agent(), |
Co-authored-by: dhuang <dhuang@fireworks.ai>
| self._session.headers.update({ | ||
| "Authorization": f"Bearer {api_key}", | ||
| "User-Agent": get_user_agent(), | ||
| }) |
There was a problem hiding this comment.
@cursor no need for tracing.fireworks.ai calls
There was a problem hiding this comment.
Done! I've removed the user-agent header from reward_function.py. The user-agent will now only be added to direct Fireworks API requests from the CLI, not to reward function endpoint calls.
Learn more about Cursor Agents
Co-authored-by: dhuang <dhuang@fireworks.ai>
|
@cursor can we DRY the code as much as possible so calls to api.fireworks.ai go through a client that always has the headers? |
|
Excellent! The refactoring is complete. Let me create a summary: SummaryI've successfully refactored the code to follow DRY principles by creating a centralized What was done:
The code is now much more maintainable with all Fireworks API requests going through a single client that ensures consistent headers across the codebase! Learn more about Cursor Agents |
This change centralizes API request logic into a new FireworksAPIClient class, simplifying and standardizing how the Fireworks API is interacted with across the project. It removes redundant request setup code and ensures consistent headers are sent. Co-authored-by: dhuang <dhuang@fireworks.ai>
| url = f"{resolved_api_base.rstrip('/')}/v1/accounts/{resolved_account_id}/secrets/{resource_id}" | ||
|
|
||
| try: | ||
| url = f"{resolved_api_base}/v1/accounts/{resolved_account_id}/secrets/{resource_id}" |
There was a problem hiding this comment.
Bug: Malformed URLs from trailing slash removal.
Removing .rstrip('/') from URL construction in platform_api.py can create malformed URLs with double slashes when resolved_api_base includes a trailing slash. This might cause HTTP request failures and is inconsistent with URL handling in other files.
This pull request contains changes generated by a Cursor Cloud Agent
Note
Adds a centralized
get_user_agent()and setsUser-Agenton Fireworks API/tracing requests across the codebase, with minor URL/header refactors.get_user_agent()returningeval-protocol/{version}.User-Agent:auth.verify_api_key_and_get_account_id()search_logs()andget_evaluation_rows()inadapters/fireworks_tracing.py.evaluation.py.fireworks_rft.py.generation/clients.py.platform_api.py.pytest/handle_persist_flow.py.api_base/urlconstruction and reuse header objects in several functions.Written by Cursor Bugbot for commit 4528c55. This will update automatically on new commits. Configure here.