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

Feat: ReAct #3998

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open

Feat: ReAct #3998

wants to merge 50 commits into from

Conversation

phact
Copy link
Collaborator

@phact phact commented Oct 3, 2024

  • Added an example ReAct test in test_cycles.py
  • Made some improvements to the Assistants components (new AssistantManager component that simplifies usage significantly, including dynamic tool usage).
  • Added SharedComponentCache and SharedComponentCache service that uses ThreadedInMemoryCache
  • Added a new ComponentWithCache to streamline usage of the new cache for things like caching connections / client objects across components. This means all the instances of all the assistants components will use the same OpenAI client.

phact and others added 30 commits September 23, 2024 14:24
The `has_cycle_edges` method is added to the `Vertex` class to check if the vertex has any cycle edges. Additionally, the `instantiate_component` method is updated to use the `initialize.loading.instantiate_class` function for custom component instantiation.
- Implement `find_cycle_vertices` function to identify all vertices that are part of cycles in a directed graph.
- Utilize depth-first search (DFS) to detect cycles and collect vertices involved in those cycles.
- Introduced `_set_cache_to_vertices_in_cycle` method to enable caching for vertices involved in cycles.
- Added `find_cycle_vertices` import to support the new method.
- Refactored vertex instantiation into `_instantiate_components_in_vertices` method for better code organization.
Refactor the `_set_cache_to_vertices_in_cycle` method to improve caching logic for vertices involved in cycles. Instead of setting the `cache` attribute to `True`, it is now set to `False` for better clarity and consistency. This change ensures that the cache is properly handled for vertices in cycles.
…and add new test case

- Removed the `entry_point` parameter from all test cases for `find_cycle_vertices`.
- Added a new parameterized test case `test_handle_two_inputs_in_cycle` to verify handling of cycles with two inputs.
…ntegration

- Introduce `test_updated_graph_with_prompts` to validate graph cyclicity and execution.
- Integrate `PromptComponent`, `OpenAIModelComponent`, and `ConditionalRouterComponent` in the test.
- Ensure graph execution with a maximum of 20 iterations and cache disabled.
- Validate the presence of expected output vertices in the results.
- Introduced `default_value` to handle cases where edges are cycles and target parameters are present.
- Ensured that `default_value` is returned if defined, preventing errors when the component is not built.
…date assertions

- Simplified component initialization using method chaining.
- Corrected router input and message parameters to use openai_component_1.
- Updated assertions to check for correct output IDs.
- Introduced `_cycle_vertices` attribute to store vertices involved in cycles.
- Added `cycle_vertices` property to compute and cache cycle vertices.
- Updated edge creation logic to use `cycle_vertices` for cycle detection.
- Changed router operator from "equals" to "contains".
- Consolidated chat output to a single component.
- Updated graph construction to use a single chat output.
- Replaced `_snapshot` with `get_snapshot` for graph state capture.
- Adjusted assertions to reflect the updated graph structure and outputs.
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Oct 3, 2024
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3998.dmtpw4p5recq1.amplifyapp.com

@phact phact changed the title ReAct Feat: ReAct Oct 3, 2024
Comment on lines +35 to +39
DropdownInput(
display_name="Tool",
name="tool",
options=tool_names,
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the tools would be Components.

What if these tools work as default ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's a way to do both, pick from the dropdown if the tools are simple and don't have any configuration or add an edge from a component for more complex tools. We would probably also want a way to accept langchain basetool tools for assistants dynamically.

Copy link
Collaborator Author

@phact phact Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also be able to pass more than one tool and let it decide which to use. Is there a multi-select input in langflow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants