-
Notifications
You must be signed in to change notification settings - Fork 31
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: Update workflow_id parameter optional in WebSocket #193
Conversation
WalkthroughThis pull request updates the chat client classes by modifying the signatures of their constructors and factory methods. The required Changes
Possibly related PRs
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
@@ Coverage Diff @@
## main #193 +/- ##
=======================================
Coverage 89.84% 89.84%
=======================================
Files 65 65
Lines 5877 5877
=======================================
Hits 5280 5280
Misses 597 597
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
cozepy/websockets/chat/__init__.py (1)
185-217
: Consider adding documentation about the optional workflow_id behaviorThe code properly implements the optional
workflow_id
parameter, but there's no documentation explaining what happens whenworkflow_id
isNone
. Adding a brief comment or docstring would improve code clarity for future developers.Consider adding a docstring like:
def __init__( self, base_url: str, auth: Auth, requester: Requester, bot_id: str, on_event: Union[WebsocketsChatEventHandler, Dict[WebsocketsEventType, Callable]], workflow_id: Optional[str] = None, **kwargs, ): + """ + Initialize a WebsocketsChatClient. + + Args: + base_url: The base URL for the API. + auth: Authentication information. + requester: The requester to use for API calls. + bot_id: The ID of the bot. + on_event: Event handler for websocket events. + workflow_id: Optional workflow ID. If None, no workflow ID will be sent in the request. + **kwargs: Additional arguments to pass to the websocket client. + """
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cozepy/websockets/chat/__init__.py
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test (Python 3.8 on macOS)
🔇 Additional comments (6)
cozepy/websockets/chat/__init__.py (6)
355-356
: Appropriate parameter modificationMaking
workflow_id
optional with a default value ofNone
aligns with the PR objectives and improves API flexibility.
364-365
: Correct implementation of workflow_id parameter passingThe parameter is passed correctly to the constructor, maintaining consistency with the changes made to the client class.
436-437
: Appropriate parameter modification for async clientMaking
workflow_id
optional in the async client matches the changes in the synchronous version, ensuring consistency across the API.
607-608
: Appropriate parameter modification for async build clientMaking
workflow_id
optional here maintains consistency with the other class modifications.
616-617
: Correct implementation of workflow_id parameter passing for asyncThe parameter is passed correctly to the async constructor, maintaining consistency.
184-185
:✅ Verification successful
Function parameter reordering could break positional arguments
The
workflow_id
parameter has been made optional, which is good. However, note that you've also changed the parameter order by movingworkflow_id
afteron_event
. This change could break existing code that uses positional arguments when instantiatingWebsocketsChatClient
.Consider checking if callers of this constructor use positional arguments or keyword arguments:
🏁 Script executed:
#!/bin/bash # Find instances where WebsocketsChatClient is instantiated rg -A 5 "WebsocketsChatClient\(" --type pyLength of output: 1650
Parameter reordering is safe as existing call sites use keyword arguments
After checking the uses of
WebsocketsChatClient
(and its async variant), all instantiations in the codebase pass parameters by keyword. There’s no evidence that any callers use positional arguments, so the reordering of parameters (withworkflow_id
now coming afteron_event
) should not break existing code. Please ensure that any external callers also use keyword arguments to avoid potential issues in the future.
Summary by CodeRabbit