-
-
Notifications
You must be signed in to change notification settings - Fork 505
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: support chat without stream #409
base: main
Are you sure you want to change the base?
fix: support chat without stream #409
Conversation
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.
Hello @yugasun, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request modifies the chat
and achat
methods in src/praisonai-agents/praisonaiagents/agent/agent.py
and the __init__
and _get_multimodal_message
methods in src/praisonai-agents/praisonaiagents/agents/agents.py
to include a stream
parameter. This allows the chat functionality to operate without streaming, providing more flexibility in how chat responses are handled. The stream
parameter is added to both synchronous and asynchronous versions of the chat methods.
Highlights
- Feature Addition: The
stream
parameter is added to thechat
andachat
methods inagent.py
to control streaming behavior. - Parameter Propagation: The
stream
parameter is passed down to the_chat_completion
and_achat_completion
methods. - Constructor Update: The
PraisonAIAgents
class constructor inagents.py
now accepts astream
parameter. - Method Update: The
_get_multimodal_message
method inagents.py
now includes thestream
parameter when calling the agent'schat
method.
Changelog
- src/praisonai-agents/praisonaiagents/agent/agent.py
- Added
stream
parameter tochat
method (line 716). - Passed
stream
parameter to_chat_completion
inchat
method (line 845). - Passed
stream
parameter to_chat_completion
when function returns an empty output (line 882). - Added
stream
parameter toachat
method (line 987). - Removed unused variable
formatted_tools
(line 1132).
- Added
- src/praisonai-agents/praisonaiagents/agents/agents.py
- Added
stream
parameter toPraisonAIAgents
constructor (line 48). - Initialized
self.stream
with the providedstream
value (line 80). - Added
stream
parameter to the agent'schat
method call in_get_multimodal_message
(line 670).
- Added
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A parameter added, a stream now controlled,
Flexibility's gained, a story unfolds.
No longer bound by constant flow,
The agent's chat, can start and go.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces a stream
parameter to enable or disable streaming in chat functionalities. The changes seem straightforward, but there are a few points to consider regarding potential breaking changes and the synchronization of asynchronous methods.
Summary of Findings
- Parameter addition without default value: The
stream
parameter was added to several methods without a default value, potentially breaking existing calls that don't provide this argument. This could lead to unexpected behavior or errors in existing integrations. - TODO comment in
achat
method: Theachat
method contains aTODO
comment indicating that it requires syncing with thechat
method. This suggests that the asynchronous version may not be fully aligned with the synchronous version, potentially leading to inconsistencies.
Merge Readiness
The pull request introduces a new feature by adding the stream
parameter to several methods. While the changes seem relatively straightforward, the potential breaking change due to the added parameter without a default value in some methods needs to be carefully considered. Additionally, the TODO
comment in the achat
method raises concerns about the consistency between synchronous and asynchronous versions. I recommend addressing these issues before merging. I am unable to approve this pull request, and users should have others review and approve this code before merging.
async def achat(self, prompt: str, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False, stream=True): | ||
"""Async version of chat method. TODO: Requires Syncing with chat method.""" |
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.
The stream
parameter is added without a default value, similar to the chat
method. Also, there's a TODO
comment indicating that this method requires syncing with the chat
method. Ensure that the asynchronous version is fully aligned with the synchronous version to avoid inconsistencies.
async def achat(self, prompt: str, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False, stream=True): | |
"""Async version of chat method. TODO: Requires Syncing with chat method.""" | |
async def achat(self, prompt: str, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False, stream=True): | |
"""Async version of chat method. Requires Syncing with chat method.""" |
48fa01f
to
fab4aca
Compare
/gemini review |
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.
Code Review
This pull request introduces a stream
parameter to the chat
methods, allowing for non-streaming responses. This is a useful addition for cases where streaming is not desired or supported. The changes look good overall.
Merge Readiness
The code changes seem correct and address the issue of supporting chat without streaming. I recommend merging this pull request after addressing the review comments. I am unable to approve the pull request, and users should have others review and approve this code before merging.
@@ -713,7 +713,7 @@ def _chat_completion(self, messages, temperature=0.2, tools=None, stream=True, r | |||
display_error(f"Error in chat completion: {e}") | |||
return None | |||
|
|||
def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False): | |||
def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False, stream=True): |
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.
Consider adding a docstring that briefly explains the purpose of the stream
parameter. This will improve the discoverability and usability of the function.
def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False, stream=True):
"""Chats with the agent.
Args:
prompt: The prompt to send to the agent.
temperature: The temperature to use for the chat completion.
tools: The tools to use for the chat completion.
output_json: Whether to output the response as JSON.
output_pydantic: Whether to output the response as a Pydantic model.
reasoning_steps: Whether to include reasoning steps in the response.
stream: Whether to stream the response.
"""
@yugasun Thank you for your contribution! Can you please review above suggestion
|
@MervinPraison Done |
No description provided.