Skip to content
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 #833

Open
Undertone0809 opened this issue Aug 3, 2024 · 1 comment
Open

Add stream output for Agent #833

Undertone0809 opened this issue Aug 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Undertone0809
Copy link
Owner

Undertone0809 commented Aug 3, 2024

🚀 Feature Request

Current, ToolAgent cannot use stream mode output. As a ReAct prompt pattern, the intermediate thought steps need to be output. Now we use hooks system to extract middle step, but agent.run(..., stream=True) is simpler.

How to do?

Add stream parameter, use agent.run(..., stream=True).

Reference: https://github.com/InternLM/MindSearch/blob/main/mindsearch/agent/mindsearch_agent.py#L196

image

@Undertone0809 Undertone0809 added the enhancement New feature or request label Aug 3, 2024
Undertone0809 added a commit that referenced this issue Aug 3, 2024
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).
@Undertone0809
Copy link
Owner Author

Undertone0809 commented Aug 3, 2024

ToolAgent + stream mode need to support output schema, but output schema only use in final output now. Need to raise error if stream=True and output_schema is not True.

Undertone0809 added a commit that referenced this issue Aug 3, 2024
Related to #833

Add stream output support for ToolAgent.

* **ToolAgent Class**:
  - Add `stream` parameter to the `run` method.
  - Implement logic to handle the `stream` parameter.
  - Modify the `_run` method to support streaming output.
  - Raise error if `stream=True` and `output_schema` is not provided.

* **BaseAgent Class**:
  - Add `stream` parameter to the `run` method.
  - Implement `_run_stream` method to handle streaming output.

* **Example**:
  - Update `example/agent/tool_agent_usage.py` to demonstrate the usage of `agent.run(..., stream=True)`.

* **Tests**:
  - 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant