-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add stream output for Agent #834
Conversation
Related to #833 Add stream mode output to ToolAgent. * Modify `promptulate/agents/tool_agent/agent.py` to add a `stream` parameter to the `run` method and implement logic to handle streaming output. * Update `example/agent/tool_agent_usage.py` to demonstrate the usage of `agent.run(..., stream=True)`. * Add tests in `tests/agents/test_tool_agent.py` to verify the stream mode output functionality. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Undertone0809/promptulate/issues/833?shareId=XXXX-XXXX-XXXX-XXXX).
WalkthroughThe changes enhance the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- example/agent/tool_agent_usage.py (1 hunks)
- promptulate/agents/tool_agent/agent.py (2 hunks)
- tests/agents/test_tool_agent.py (1 hunks)
Additional context used
Ruff
promptulate/agents/tool_agent/agent.py
122-122: Line too long (93 > 88)
(E501)
Additional comments not posted (3)
example/agent/tool_agent_usage.py (1)
13-14
: LGTM! Ensure proper usage of the new streaming functionality.The code changes are approved. The for-loop correctly handles streaming responses from
agent.run
.However, ensure that all function calls to
agent.run
withstream=True
are correctly handled in the codebase.tests/agents/test_tool_agent.py (1)
58-64
: LGTM! Ensure comprehensive test coverage.The code changes are approved. The test function correctly tests the streaming functionality of
ToolAgent
.However, ensure that the test coverage is comprehensive and includes edge cases.
promptulate/agents/tool_agent/agent.py (1)
178-180
: LGTM! Ensure proper usage of the new streaming functionality.The code changes are approved. The changes correctly handle streaming responses by yielding results if
stream
isTrue
.However, ensure that all method calls to
_run
withstream=True
are correctly handled in the codebase.
@@ -119,13 +119,14 @@ def current_date(self) -> str: | |||
return f"Current date: {time.strftime('%Y-%m-%d %H:%M:%S')}" | |||
|
|||
def _run( | |||
self, instruction: str, return_raw_data: bool = False, **kwargs | |||
self, instruction: str, return_raw_data: bool = False, stream: bool = False, **kwargs |
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.
Refactor for line length.
The line exceeds the maximum line length of 88 characters.
- self, instruction: str, return_raw_data: bool = False, stream: bool = False, **kwargs
+ self, instruction: str, return_raw_data: bool = False,
+ stream: bool = False, **kwargs
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
self, instruction: str, return_raw_data: bool = False, stream: bool = False, **kwargs | |
self, instruction: str, return_raw_data: bool = False, | |
stream: bool = False, **kwargs |
Tools
Ruff
122-122: Line too long (93 > 88)
(E501)
Related to #833
Add stream mode output to ToolAgent.
promptulate/agents/tool_agent/agent.py
to add astream
parameter to therun
method and implement logic to handle streaming output.example/agent/tool_agent_usage.py
to demonstrate the usage ofagent.run(..., stream=True)
.tests/agents/test_tool_agent.py
to verify the stream mode output functionality.For more details, open the Copilot Workspace session.
Summary by CodeRabbit
New Features
Bug Fixes
_run
method to allow optional streaming output, ensuring better responsiveness during LLM interactions.Tests