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: Implement tool mode functionality and dynamic placeholders across input components #4402

Merged
merged 625 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
625 commits
Select commit Hold shift + click to select a range
6c0aa8b
fix: update message streaming logic to handle None messages and refac…
ogabrielluiz Nov 1, 2024
ce78798
feat: include flow_id in ChatOutput initialization
ogabrielluiz Nov 1, 2024
38163c4
fix: update chat message source display to use 'source' instead of 'd…
ogabrielluiz Nov 1, 2024
b73a4ca
feat: add flow_id to message initialization in ChatOutput class
ogabrielluiz Nov 1, 2024
be4bef8
fix: handle JSON parsing with type checks for message properties
ogabrielluiz Nov 1, 2024
cc92fe3
refactor: update logging structure and message handling
ogabrielluiz Nov 1, 2024
f41fee1
feat: restrict event types in registration and sending
ogabrielluiz Nov 1, 2024
84bb160
Update `logs` attribute to store lists of `Log` objects in `Vertex` c…
ogabrielluiz Nov 1, 2024
65b9c61
feat: introduce TypedDicts for ContentBlock and Properties, update de…
ogabrielluiz Nov 1, 2024
93c6f27
fix: restrict event types in send_event method to improve data valida…
ogabrielluiz Nov 1, 2024
527ea4f
Set default values for 'id', 'display_name', and 'source' fields in S…
ogabrielluiz Nov 1, 2024
c3a30ee
Merge remote-tracking branch 'origin/main' into add-new-schema
anovazzi1 Nov 1, 2024
3744f03
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 1, 2024
e4e0b93
fix: update query to use equality check for error messages
ogabrielluiz Nov 4, 2024
3a6f510
Merge branch 'main' into add-new-schema
anovazzi1 Nov 4, 2024
1f43399
Merge branch 'main' into add-new-schema
ogabrielluiz Nov 4, 2024
5a46822
make lint
anovazzi1 Nov 4, 2024
20b6e2a
update simple agent test
anovazzi1 Nov 4, 2024
89b35d4
test: enhance EventManager tests for event_id validation
ogabrielluiz Nov 4, 2024
6b50b41
feat: add background, chat icon, and text color properties to compone…
ogabrielluiz Nov 4, 2024
08db972
fix: update LogComponent name to display_name for consistency
ogabrielluiz Nov 4, 2024
cff372c
remove playground from new cards on main page
anovazzi1 Nov 4, 2024
605e4d0
Merge branch 'main' into add-new-schema
anovazzi1 Nov 4, 2024
4fe7920
refactor: Update Properties handling in MessageTable and remove unuse…
ogabrielluiz Nov 4, 2024
9426d2e
fix: Set default value for category in MessageBase model
ogabrielluiz Nov 4, 2024
c951a1f
fix: Update properties default factory in MessageTable model to use m…
ogabrielluiz Nov 4, 2024
4f783b9
Add _build_source method to ChatOutput and update test inputs to use …
ogabrielluiz Nov 4, 2024
317b2b8
Fix incorrect parameter names in _build_source method across multiple…
ogabrielluiz Nov 4, 2024
e5201c5
Merge branch 'main' into add-new-schema
anovazzi1 Nov 4, 2024
520fa88
✅ (freeze.spec.ts, playground.spec.ts, stop-building.spec.ts, linkCom…
Cristhianzl Nov 4, 2024
1be682d
Merge branch 'main' into add-new-schema
ogabrielluiz Nov 4, 2024
9f9b3c1
Refactor agent event processing to support message streaming and impr…
ogabrielluiz Nov 4, 2024
4a351fa
Refactor ChatOutput to enhance message handling and streamline proper…
ogabrielluiz Nov 4, 2024
2e7ab29
Fix session ID assignment in send_message method for better message h…
ogabrielluiz Nov 4, 2024
d70c449
Add OnTokenFunctionType protocol for enhanced token handling
ogabrielluiz Nov 4, 2024
66c23ab
Add BorderTrail component for animated border effects
ogabrielluiz Nov 4, 2024
e97c6cf
Add ContentBlockDisplay component for enhanced content visualization …
ogabrielluiz Nov 4, 2024
7bc3895
Refactor TextShimmer to use motion.create for improved component anim…
ogabrielluiz Nov 4, 2024
cb1dd65
Add ContentBlockDisplay to render chat content blocks in newChatMessa…
ogabrielluiz Nov 4, 2024
2797f80
Refactor `ChatOutput` class to use `MessageInput` instead of `Message…
ogabrielluiz Nov 4, 2024
6e543c6
Update edge class name from 'runned' to 'ran' in flow components and …
ogabrielluiz Nov 4, 2024
97cdc8a
Add 'on_build_start' and 'on_build_end' events to EventManager
ogabrielluiz Nov 4, 2024
3310ab9
Add build status updates for 'build_start' and 'build_end' events in …
ogabrielluiz Nov 4, 2024
2d8bf3f
Integrate event management for output function in ComponentToolkit to…
ogabrielluiz Nov 4, 2024
26dd741
Refactor event handling in ComponentToolkit to improve build event tr…
ogabrielluiz Nov 4, 2024
c32a0dd
Refactor messagesStore to update existing message if it already exists
anovazzi1 Nov 4, 2024
bbc5e97
update properties to have state attribute
anovazzi1 Nov 4, 2024
96b8c41
format
anovazzi1 Nov 4, 2024
802b0b9
Refactor chatMessage component to display loading state for partial c…
anovazzi1 Nov 4, 2024
d20bc67
Refactor reactflowUtils to handle broken edges with missing display n…
anovazzi1 Nov 4, 2024
00c76bb
fix agent text output
anovazzi1 Nov 4, 2024
593b3ce
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 4, 2024
fe283ef
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 4, 2024
9646da4
fix agent component initialization
ogabrielluiz Nov 5, 2024
9314fb3
Enhance error message formatting to include detailed exception inform…
ogabrielluiz Nov 5, 2024
def4a93
Refactor agent component for improved performance and stability
ogabrielluiz Nov 5, 2024
fc63b74
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 5, 2024
13a2c25
Refactor `LCAgentComponent` to streamline agent execution logic and r…
ogabrielluiz Nov 5, 2024
78f784c
Add type casting for send_message function in agent.py
ogabrielluiz Nov 5, 2024
69936e5
Change return type of function to 'Message' in log schema
ogabrielluiz Nov 5, 2024
322c7af
Add `embedding_service` and `client` fields to JSON configurations an…
ogabrielluiz Nov 5, 2024
4667e64
Update attribute handling in Component class to merge inputs with exi…
ogabrielluiz Nov 5, 2024
a9e69f4
Update ChatInput and ChatOutput initialization to include session_id
ogabrielluiz Nov 5, 2024
142aa2d
Refactor test_load_flow_from_json_object to be asynchronous
ogabrielluiz Nov 5, 2024
50535a1
Add asynchronous tests for agent event handling in test_agent_events.py
ogabrielluiz Nov 5, 2024
1f61b17
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 5, 2024
3a67bae
Add event handling functions for agent tool and chain events
ogabrielluiz Nov 5, 2024
f86c14e
feat: update content structure and validation logic
ogabrielluiz Nov 5, 2024
5bfd301
Handle ValidationError in error message generation and update import …
ogabrielluiz Nov 5, 2024
39d3a90
feat: enhance error event creation to include structured error content
ogabrielluiz Nov 5, 2024
7ada366
move validators and remove utils.py
ogabrielluiz Nov 5, 2024
a06d95d
feat: add event handler tests for agent tool and chain events
ogabrielluiz Nov 5, 2024
dc46a33
refactor: streamline tool content structure
ogabrielluiz Nov 5, 2024
de717ce
feat: refactor error handling in ChatMessage component to support dyn…
ogabrielluiz Nov 5, 2024
c380f12
feat: enhance ContentBlockDisplay to support Markdown rendering and d…
ogabrielluiz Nov 5, 2024
76157e0
Refactor agent event handling to simplify content block management
ogabrielluiz Nov 5, 2024
61a664a
Enhance `ContentBlockDisplay` with separators and improved content re…
ogabrielluiz Nov 5, 2024
c52dcad
add inline block to prevent text overflow in reason
anovazzi1 Nov 5, 2024
a123a97
Refactor code to enhance Markdown rendering and dynamic content handl…
anovazzi1 Nov 5, 2024
27c76ef
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 5, 2024
e803b2a
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 5, 2024
32ff99b
Add timestamp field to BaseContent class and remove from ToolContent …
ogabrielluiz Nov 5, 2024
2831e68
Update timestamp validation to include fractional seconds in BaseCont…
ogabrielluiz Nov 5, 2024
4bab2c9
Add duration calculation for agent and tool events in events.py
ogabrielluiz Nov 5, 2024
f8c0260
Refactor ContentBlock to use Pydantic's Discriminator and Tag for con…
ogabrielluiz Nov 5, 2024
5b6e193
Add field validators for content_blocks and properties in Message class
ogabrielluiz Nov 5, 2024
2a6cfc5
Add field serializer for source in Properties class
ogabrielluiz Nov 5, 2024
0185859
Add type hint for serialize_properties method in MessageTable class
ogabrielluiz Nov 5, 2024
1cc41ce
create duration component and refactor contents
anovazzi1 Nov 5, 2024
626a0e9
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 5, 2024
8d35383
Refactor duration calculation to use perf_counter for improved accura…
ogabrielluiz Nov 5, 2024
81d4a8b
Update properties field validator to use 'before' mode for improved v…
ogabrielluiz Nov 5, 2024
8b63e55
Refactor MessageTable to use ContentBlock instead of ContentBlockDict…
ogabrielluiz Nov 5, 2024
e4b684c
Refactor AgentComponent to streamline agent initialization by using t…
ogabrielluiz Nov 5, 2024
b9255af
Refactor event handling functions to use synchronous definitions and …
ogabrielluiz Nov 5, 2024
6713f08
Refactor PythonREPLToolComponent to raise ToolException on error inst…
ogabrielluiz Nov 5, 2024
96889c2
Refactor CalculatorToolComponent to enhance error handling by raising…
ogabrielluiz Nov 5, 2024
65a55bd
Fix TextShimmer width in ContentBlockDisplay for improved layout cons…
ogabrielluiz Nov 5, 2024
8d99863
Enhance ContentBlockDisplay to support external links and math render…
ogabrielluiz Nov 5, 2024
537c8af
Enhance error handling in Calculator and Python REPL tools by introdu…
ogabrielluiz Nov 5, 2024
ce05a84
Refactor agent message properties to remove unnecessary icons and upd…
ogabrielluiz Nov 5, 2024
823ca39
feat: enhance agent and tool content messaging
ogabrielluiz Nov 5, 2024
f03c98f
Handle nested schema structure in ContentBlock initialization
ogabrielluiz Nov 5, 2024
d393211
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 5, 2024
985124e
fix: update agent input text content return type and enhance error me…
ogabrielluiz Nov 5, 2024
6a89125
Add placeholder and default value for model selection in AstraVectorS…
ogabrielluiz Nov 5, 2024
c68308c
Refactor event handling functions to remove `send_message_method` par…
ogabrielluiz Nov 5, 2024
335f044
Add model configuration to ToolContent for alias population
ogabrielluiz Nov 5, 2024
5b3cf01
Refactor agent event tests to improve message handling and content bl…
ogabrielluiz Nov 5, 2024
0087384
test: Update test durations for performance metrics
ogabrielluiz Nov 5, 2024
ee13299
Refactor test_load_flow_from_json_object to improve project loading l…
ogabrielluiz Nov 5, 2024
60ca0d0
Make `HeaderDict` fields optional and update `header` field in `BaseC…
ogabrielluiz Nov 5, 2024
de45718
Enhance `Message` and `ChatOutput` with additional attributes for tes…
ogabrielluiz Nov 5, 2024
f7b371d
Update test duration metrics in .test_durations file
ogabrielluiz Nov 5, 2024
e66cff5
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 5, 2024
49c8de5
Refactor `ContentDisplay` component to support multiple content types…
ogabrielluiz Nov 6, 2024
ed71ad4
feat: Enhance duration display with human-readable format
ogabrielluiz Nov 6, 2024
cbe4677
feat: Add optional duration and header properties to BaseContent inte…
ogabrielluiz Nov 6, 2024
7d9dd84
fix: Change duration type from float to int in BaseContent class
ogabrielluiz Nov 6, 2024
a2da1b8
Remove default value for 'start_time' in duration calculations
ogabrielluiz Nov 6, 2024
36f7bd2
Enhance `ContentBlockDisplay` with dynamic header and expand/collapse…
ogabrielluiz Nov 6, 2024
35d2b4e
Add animation to header title using AnimatePresence and motion compon…
ogabrielluiz Nov 6, 2024
94da63a
Add support for processing zip files with multithreading in FileCompo…
ogabrielluiz Nov 6, 2024
4568a34
Expand `Message` conversion to support `AsyncIterator` and `Iterator`…
ogabrielluiz Nov 6, 2024
671cf55
Remove unused function _find_or_create_tool_content from events.py
ogabrielluiz Nov 6, 2024
01978a4
Add header information to tool content and streamline message sending…
ogabrielluiz Nov 6, 2024
22d9003
Add send_message_method parameter to event handlers for message dispa…
ogabrielluiz Nov 6, 2024
8aa3e97
Refactor ContentBlockDisplay component to improve rendering performan…
anovazzi1 Nov 6, 2024
165ad1d
Refactor `ContentBlockDisplay.tsx` to improve readability and update …
ogabrielluiz Nov 6, 2024
d47ab4a
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 6, 2024
c58a535
Add 'start_time' to event data and update test functions to include s…
ogabrielluiz Nov 6, 2024
141e9b8
Refactor ContentBlockDisplay component to include total duration and …
anovazzi1 Nov 6, 2024
1dadf10
Refactor ContentBlockDisplay component to handle isLoading state for …
anovazzi1 Nov 6, 2024
d16605f
Refactor animatedNumbers component and add AnimatedNumberBasic component
anovazzi1 Nov 6, 2024
97a48ee
Refactor agent message creation to improve event processing efficiency
ogabrielluiz Nov 6, 2024
5c92413
Refactor session ID assignment in run_graph_internal for improved cla…
ogabrielluiz Nov 6, 2024
005557e
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 6, 2024
fd10b2f
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 6, 2024
4ca8c62
fix: update agent message properties handling for improved compatibility
ogabrielluiz Nov 6, 2024
2596238
fix: enhance message property validation to support dictionary input
ogabrielluiz Nov 6, 2024
1aaf584
Add session_id to agent message initialization in tests
ogabrielluiz Nov 6, 2024
37ab2ab
feat: Enhance event handling with duration tracking
ogabrielluiz Nov 6, 2024
1a5e4ad
Add optional humanized value to AnimatedNumber component and update D…
ogabrielluiz Nov 6, 2024
1ecbda5
Refactor `ContentDisplay` and add separator to `ContentBlockDisplay` …
ogabrielluiz Nov 6, 2024
1ba36f6
Add header to text content in agent message events
ogabrielluiz Nov 6, 2024
0f5de6e
Add separator between each content block in ContentBlockDisplay compo…
ogabrielluiz Nov 6, 2024
97dfd7a
Refactor layout in ContentDisplay component for improved styling and …
ogabrielluiz Nov 6, 2024
b93f91c
Refactor event handlers to return updated start_time and agent_message
ogabrielluiz Nov 6, 2024
6633a50
Add start_time and duration checks to agent event handlers in tests
ogabrielluiz Nov 6, 2024
e459c4d
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 6, 2024
4dcd454
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 6, 2024
6308936
update colors and spacing of time
anovazzi1 Nov 6, 2024
eb8c795
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 6, 2024
a201ee1
Refactor DurationDisplay component to display duration in seconds
anovazzi1 Nov 6, 2024
fee5a15
Rename case from "message" to "add_message" in buildUtils.ts switch s…
ogabrielluiz Nov 6, 2024
1d91b48
Add event registration for message removal in EventManager
ogabrielluiz Nov 6, 2024
60b16f4
Add category handling for message events in Component class
ogabrielluiz Nov 6, 2024
8c43d38
Add custom exception handling for agent message processing
ogabrielluiz Nov 6, 2024
24cf942
Handle exceptions in agent event processing with message deletion and…
ogabrielluiz Nov 6, 2024
b8a1604
Add new LLM options and refactor AgentComponent for dynamic provider …
ogabrielluiz Nov 6, 2024
f13bd8f
Refactor buildUtils.ts and add message removal handling
anovazzi1 Nov 6, 2024
cf01462
Merge branch 'main' into stream-events-agent
ogabrielluiz Nov 6, 2024
f11db8a
Update Source model to allow None values for id, display_name, and so…
ogabrielluiz Nov 6, 2024
6ae1669
Refactor event handler functions to return tuple of Message and float
ogabrielluiz Nov 6, 2024
307314f
Refactor `ChatOutput` class to use `MessageInput` instead of `Message…
ogabrielluiz Nov 4, 2024
a29266f
Add test for updating component outputs with dynamic code input
ogabrielluiz Oct 28, 2024
28b89bc
feat: add ToolModeMixin to manage tool mode state
ogabrielluiz Nov 2, 2024
c6e1b14
feat: add parameterName to mutateTemplate for enhanced template mutation
ogabrielluiz Nov 2, 2024
e40d0dc
feat: add tool mode functionality to node toolbar
ogabrielluiz Nov 2, 2024
6424912
feat: integrate ToolModeMixin into MessageTextInput for enhanced func…
ogabrielluiz Nov 2, 2024
5b2d6ef
Update parameterId to "tool_mode" in nodeToolbarComponent
ogabrielluiz Nov 2, 2024
a92a699
feat: implement tool mode output handling in run_and_validate_update_…
ogabrielluiz Nov 2, 2024
a79a1b5
feat: add conditional rendering for tool mode button based on templat…
ogabrielluiz Nov 2, 2024
2d2241b
fix: enhance null checks for tool mode button visibility and output v…
ogabrielluiz Nov 2, 2024
4b057ce
feat: add isToolMode property to NodeInputFieldComponentType for enha…
ogabrielluiz Nov 2, 2024
06eacba
feat: add isToolMode prop to NodeInputField for conditional styling
ogabrielluiz Nov 2, 2024
c78e035
feat: implement sorting logic for tool mode fields in GenericNode com…
ogabrielluiz Nov 2, 2024
5bfb3d4
feat: add isToolMode prop to NodeOutputField for conditional styling
ogabrielluiz Nov 2, 2024
617d9ec
feat: pass isToolMode prop to NodeOutputField for conditional styling
ogabrielluiz Nov 2, 2024
f5d2fb6
feat: update disabled logic in NodeInputField to include isToolMode
ogabrielluiz Nov 4, 2024
8f07c9d
Add default placeholder to getPlaceholder function and constants file
ogabrielluiz Nov 4, 2024
2f60469
feat: Enable dynamic placeholders in input components
ogabrielluiz Nov 4, 2024
482c71e
feat: Add optional placeholder prop to InputProps type
ogabrielluiz Nov 4, 2024
3763c8f
feat: Add placeholder prop to InputGlobalComponent and CustomParamete…
ogabrielluiz Nov 4, 2024
e58e83d
feat: Set dynamic placeholder for NodeInputField based on tool mode
ogabrielluiz Nov 4, 2024
ec66454
feat: Update NodeOutputField styling for tool mode and pass isToolMod…
ogabrielluiz Nov 4, 2024
bdb6849
feat: Add isToolMode prop to OutputComponent for dynamic styling
ogabrielluiz Nov 4, 2024
656f6ad
feat: Add TOOL_OUTPUT_DISPLAY_NAME constant for toolset display
ogabrielluiz Nov 4, 2024
722a8d9
feat: Update tool output display name to use TOOL_OUTPUT_DISPLAY_NAME…
ogabrielluiz Nov 4, 2024
7554be7
feat: Conditionally render Freeze Path button based on tool mode
ogabrielluiz Nov 4, 2024
5edcc08
Add support for asynchronous output methods and tool mode validation …
ogabrielluiz Nov 4, 2024
42e34c8
feat: Validate required inputs for tool mode before executing output …
ogabrielluiz Nov 4, 2024
641531e
Refactor: Rename method to indicate private access in custom_component
ogabrielluiz Nov 4, 2024
615d360
feat: Implement tool output mapping based on tool mode presence in in…
ogabrielluiz Nov 4, 2024
e996933
Refactor tests to use private method _get_function_entrypoint_return_…
ogabrielluiz Nov 4, 2024
d16aded
feat: Enable tool mode for input_value in LCAgentComponent
ogabrielluiz Nov 5, 2024
f47cf12
Add test for updating component outputs with dynamic code input
ogabrielluiz Oct 28, 2024
6cce4bc
feat: add tool mode functionality to node toolbar
ogabrielluiz Nov 2, 2024
3bed63e
feat: add conditional rendering for tool mode button based on templat…
ogabrielluiz Nov 2, 2024
5969f18
feat: add isToolMode prop to NodeInputField for conditional styling
ogabrielluiz Nov 2, 2024
427e043
feat: Set dynamic placeholder for NodeInputField based on tool mode
ogabrielluiz Nov 4, 2024
6ea7ff9
feat: Add TOOL_OUTPUT_DISPLAY_NAME constant for toolset display
ogabrielluiz Nov 4, 2024
3b09153
feat: Conditionally render Freeze Path button based on tool mode
ogabrielluiz Nov 4, 2024
cd500e9
Add tool mode support to LCAgentComponent
ogabrielluiz Nov 6, 2024
cc05867
Fix return statement placement in event handling logic
ogabrielluiz Nov 6, 2024
cef3e35
Add tool mode enhancements and error handling in component_tool
ogabrielluiz Nov 6, 2024
802226b
Refactor agent response method and update output configuration
ogabrielluiz Nov 6, 2024
48bed49
Remove unused 'input_value' field from tool_calling.py configuration
ogabrielluiz Nov 6, 2024
85b40f4
Refactor source property assignment to use _build_source method
ogabrielluiz Nov 6, 2024
4d2ae7d
Enhance callable input check and add callbacks to toolkit conversion
ogabrielluiz Nov 6, 2024
90e724b
Add unit tests for message update functionality in backend
ogabrielluiz Nov 6, 2024
435efc2
Add field serializer for 'output' using jsonable_encoder in content_t…
ogabrielluiz Nov 6, 2024
07540c4
Add tool mode fields and refactor message response in starter projects
ogabrielluiz Nov 6, 2024
9d4387d
Implement no-op send_message function and patching decorator for comp…
ogabrielluiz Nov 6, 2024
d411a1b
Refactor output handling in component tool to support Message and Dat…
ogabrielluiz Nov 6, 2024
cc999bc
Simplify exception handling by removing redundant exception re-raise
ogabrielluiz Nov 6, 2024
830591c
Enhance tool assignment logic to preserve existing name and descripti…
ogabrielluiz Nov 7, 2024
50b38ff
feat: Enhance agent name and description handling
ogabrielluiz Nov 7, 2024
2e46d9e
refactor: Update agent description and name info to include default v…
ogabrielluiz Nov 7, 2024
b404fb5
Merge branch 'main' into add-tool-mode-to-field
ogabrielluiz Nov 7, 2024
bf04794
Add custom encoders for serialization and refactor schema modules
ogabrielluiz Nov 7, 2024
fe10b39
Remove 'agent_name' field and update 'get_tool_name' method in agent.py
ogabrielluiz Nov 7, 2024
a7a0984
Enhance `serialize_model` method with `wrap` mode and improved error …
ogabrielluiz Nov 7, 2024
319bd83
Add 'tool_mode' attribute to frontend node class
ogabrielluiz Nov 7, 2024
65e2d8e
Add unit tests for ContentBlock initialization and content handling
ogabrielluiz Nov 7, 2024
5acb7d8
Add unit tests for content types serialization and creation
ogabrielluiz Nov 7, 2024
f35a707
Refactor tool mode initialization logic in NodeToolbarComponent
ogabrielluiz Nov 7, 2024
8fd76a4
Add tool mode functionality to node toolbar and flow store
ogabrielluiz Nov 7, 2024
bc93484
Add updateNodeInternals call for tool_mode case in nodeToolbarComponent
ogabrielluiz Nov 7, 2024
9e1205c
Add condition to hide handle in tool mode in NodeInputField component
ogabrielluiz Nov 7, 2024
3c205e1
Add shortcut for activating Tool Mode and integrate into node toolbar
ogabrielluiz Nov 7, 2024
04db6df
Add tool_mode parameter to MessageTextInput and update attributes map…
ogabrielluiz Nov 7, 2024
952fd57
Remove 'agent_name' field from Agent Flow configuration file
ogabrielluiz Nov 7, 2024
b106055
Update agent message to use display_name instead of agent_name
ogabrielluiz Nov 7, 2024
1998cc1
Add validation for required tools in agent execution and component setup
ogabrielluiz Nov 7, 2024
5ce72be
Make 'tools' field required in AgentComponent configuration
ogabrielluiz Nov 7, 2024
93a8755
test: add unit tests for run_and_validate_update_outputs functionality
ogabrielluiz Nov 7, 2024
372dca1
Merge branch 'main' into add-tool-mode-to-field
ogabrielluiz Nov 7, 2024
524ac35
test: update component toolkit tests to use CalculatorToolComponent
ogabrielluiz Nov 8, 2024
6baf28a
Enhance input schema creation logic for tool mode components
ogabrielluiz Nov 8, 2024
e75630a
Include input expression in error responses for calculator tool
ogabrielluiz Nov 8, 2024
3f24989
Enhance `visit_Attribute` to check for required inputs in `tree_visit…
ogabrielluiz Nov 8, 2024
2bb5604
fix: add checks for graph attribute before accessing session and flow…
ogabrielluiz Nov 8, 2024
64ef526
fix: set default value to None for id field in PlaygroundEvent model
ogabrielluiz Nov 8, 2024
59b8967
fix: remove unused add_toolkit_output flag from FeatureFlags model
ogabrielluiz Nov 8, 2024
7e5f591
Refactor JSON configurations to remove unnecessary required inputs ac…
ogabrielluiz Nov 8, 2024
38ad9a7
Add tool mode validation and improve error handling
ogabrielluiz Nov 8, 2024
deebd11
Add pytest fixture to test_component_message_sending test
ogabrielluiz Nov 8, 2024
48c3844
fix linkComponent test
phact Nov 8, 2024
f3b641c
Skip flaky test in stop-building.spec.ts
ogabrielluiz Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions src/backend/base/langflow/base/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from langflow.base.agents.events import ExceptionWithMessageError, process_agent_events
from langflow.base.agents.utils import data_to_messages
from langflow.custom import Component
from langflow.inputs.inputs import InputTypes
from langflow.custom.custom_component.component import _get_component_toolkit
from langflow.field_typing import Tool
from langflow.inputs.inputs import InputTypes, MultilineInput
from langflow.io import BoolInput, HandleInput, IntInput, MessageTextInput
from langflow.memory import delete_message
from langflow.schema import Data
Expand All @@ -24,10 +26,19 @@
from langchain_core.messages import BaseMessage


DEFAULT_TOOLS_DESCRIPTION = "A helpful assistant with access to the following tools:"
DEFAULT_AGENT_NAME = "Agent ({tools_names})"


class LCAgentComponent(Component):
trace_type = "agent"
_base_inputs: list[InputTypes] = [
MessageTextInput(name="input_value", display_name="Input"),
MessageTextInput(
name="input_value",
display_name="Input",
info="The input provided by the user for the agent to process.",
tool_mode=True,
),
BoolInput(
name="handle_parsing_errors",
display_name="Handle Parse Errors",
Expand All @@ -46,6 +57,16 @@ class LCAgentComponent(Component):
value=15,
advanced=True,
),
MultilineInput(
name="agent_description",
display_name="Agent Description",
info=(
"The description of the agent. This is only used when in Tool Mode. "
f"Defaults to '{DEFAULT_TOOLS_DESCRIPTION}' and tools are added dynamically."
),
advanced=True,
value=DEFAULT_TOOLS_DESCRIPTION,
),
]

outputs = [
Expand Down Expand Up @@ -117,7 +138,7 @@ async def run_agent(

agent_message = Message(
sender=MESSAGE_SENDER_AI,
sender_name="Agent",
sender_name=self.display_name or "Agent",
properties={"icon": "Bot", "state": "partial"},
content_blocks=[ContentBlock(title="Agent Steps", contents=[])],
session_id=self.graph.session_id,
Expand All @@ -136,7 +157,7 @@ async def run_agent(
msg_id = e.agent_message.id
await asyncio.to_thread(delete_message, id_=msg_id)
self._send_message_event(e.agent_message, category="remove_message")
raise e.exception # noqa: B904
raise
except Exception:
raise

Expand Down Expand Up @@ -167,3 +188,28 @@ def build_agent(self) -> AgentExecutor:
@abstractmethod
def create_agent_runnable(self) -> Runnable:
"""Create the agent."""

def get_tool_name(self) -> str:
return self.display_name

def get_tool_description(self) -> str:
return self.agent_description or DEFAULT_TOOLS_DESCRIPTION

def _build_tools_names(self):
tools_names = ""
if self.tools:
tools_names = ", ".join([tool.name for tool in self.tools])
return tools_names

def to_toolkit(self) -> list[Tool]:
component_toolkit = _get_component_toolkit()
tools_names = self._build_tools_names()
agent_description = self.get_tool_description()
# Check if tools_description is the default value
if agent_description == DEFAULT_TOOLS_DESCRIPTION:
description = f"{agent_description}{tools_names}"
else:
description = agent_description
return component_toolkit(component=self).get_tools(
tool_name=self.get_tool_name(), tool_description=description, callbacks=self.get_langchain_callbacks()
)
2 changes: 1 addition & 1 deletion src/backend/base/langflow/base/agents/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,6 @@ async def process_agent_events(
agent_message, start_time = chain_handler(event, agent_message, send_message_method, start_time)
start_time = start_time or perf_counter()
agent_message.properties.state = "complete"
return Message(**agent_message.model_dump())
except Exception as e:
raise ExceptionWithMessageError(e, agent_message) from e
return Message(**agent_message.model_dump())
154 changes: 136 additions & 18 deletions src/backend/base/langflow/base/tools/component_tool.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
from __future__ import annotations

import asyncio
import re
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Literal

from langchain_core.tools import ToolException
from langchain_core.tools.structured import StructuredTool
from loguru import logger
from pydantic import BaseModel

from langflow.base.tools.constants import TOOL_OUTPUT_NAME
from langflow.io.schema import create_input_schema
from langflow.schema.data import Data
from langflow.schema.message import Message

if TYPE_CHECKING:
from collections.abc import Callable

from langchain_core.callbacks import Callbacks
from langchain_core.tools import BaseTool

from langflow.custom.custom_component.component import Component
from langflow.events.event_manager import EventManager
from langflow.inputs.inputs import InputTypes
from langflow.io import Output
from langflow.schema.content_types import ContentBlock


def _get_input_type(_input: InputTypes):
Expand Down Expand Up @@ -47,10 +53,57 @@ def build_description(component: Component, output: Output) -> str:
return f"{output.method}({args}) - {component.description}"


def send_message_noop(
message: Message | None = None,
text: str | None = None, # noqa: ARG001
background_color: str | None = None, # noqa: ARG001
text_color: str | None = None, # noqa: ARG001
icon: str | None = None, # noqa: ARG001
content_blocks: list[ContentBlock] | None = None, # noqa: ARG001
format_type: Literal["default", "error", "warning", "info"] = "default", # noqa: ARG001
id_: str | None = None, # noqa: ARG001
*,
allow_markdown: bool = True, # noqa: ARG001
) -> Message:
"""No-op implementation of send_message."""
return message


def patch_components_send_message(component: Component):
old_send_message = component.send_message
component.send_message = send_message_noop
return old_send_message


def _patch_send_message_decorator(component, func):
"""Decorator to patch the send_message method of a component.

This is useful when we want to use a component as a tool, but we don't want to
send any messages to the UI. With this only the Component calling the tool
will send messages to the UI.
"""

async def async_wrapper(*args, **kwargs):
original_send_message = component.send_message
component.send_message = send_message_noop
try:
return await func(*args, **kwargs)
finally:
component.send_message = original_send_message

def sync_wrapper(*args, **kwargs):
original_send_message = component.send_message
component.send_message = send_message_noop
try:
return func(*args, **kwargs)
finally:
component.send_message = original_send_message

return async_wrapper if asyncio.iscoroutinefunction(func) else sync_wrapper


def _build_output_function(component: Component, output_method: Callable, event_manager: EventManager | None = None):
def output_function(*args, **kwargs):
# set the component with the arguments
# set functionality was updatedto handle list of components and other values separately
try:
if event_manager:
event_manager.on_build_start(data={"id": component._id})
Expand All @@ -60,10 +113,40 @@ def output_function(*args, **kwargs):
event_manager.on_build_end(data={"id": component._id})
except Exception as e:
raise ToolException(e) from e
else:
return result

return output_function
if isinstance(result, Message):
return result.get_text()
if isinstance(result, Data):
return result.data
if isinstance(result, BaseModel):
return result.model_dump()
return result

return _patch_send_message_decorator(component, output_function)


def _build_output_async_function(
component: Component, output_method: Callable, event_manager: EventManager | None = None
):
async def output_function(*args, **kwargs):
try:
if event_manager:
event_manager.on_build_start(data={"id": component._id})
component.set(*args, **kwargs)
result = await output_method()
if event_manager:
event_manager.on_build_end(data={"id": component._id})
except Exception as e:
raise ToolException(e) from e
if isinstance(result, Message):
return result.get_text()
if isinstance(result, Data):
return result.data
if isinstance(result, BaseModel):
return result.model_dump()
return result

return _patch_send_message_decorator(component, output_function)


def _format_tool_name(name: str):
Expand All @@ -77,7 +160,9 @@ class ComponentToolkit:
def __init__(self, component: Component):
self.component = component

def get_tools(self) -> list[BaseTool]:
def get_tools(
self, tool_name: str | None = None, tool_description: str | None = None, callbacks: Callbacks | None = None
) -> list[BaseTool]:
tools = []
for output in self.component.outputs:
if output.name == TOOL_OUTPUT_NAME:
Expand All @@ -89,23 +174,56 @@ def get_tools(self) -> list[BaseTool]:

output_method: Callable = getattr(self.component, output.method)
args_schema = None
tool_mode_inputs = [_input for _input in self.component.inputs if getattr(_input, "tool_mode", False)]
if output.required_inputs:
inputs = [self.component._inputs[input_name] for input_name in output.required_inputs]
# If any of the required inputs are not in tool mode, this means
# that when the tool is called it will raise an error.
# so we should raise an error here.
if not all(getattr(_input, "tool_mode", False) for _input in inputs):
non_tool_mode_inputs = [input_.name for input_ in inputs if not getattr(input_, "tool_mode", False)]
msg = (
f"Output '{output.name}' requires inputs that are not in tool mode. "
f"The following inputs are not in tool mode: {', '.join(non_tool_mode_inputs)}. "
"Please ensure all required inputs are set to tool mode."
)
raise ValueError(msg)
args_schema = create_input_schema(inputs)
else:
args_schema = create_input_schema(self.component.inputs)
args_schema = create_input_schema(tool_mode_inputs)
name = f"{self.component.name}.{output.method}"
formatted_name = _format_tool_name(name)
tools.append(
StructuredTool(
name=formatted_name,
description=build_description(component=self.component, output=output),
func=_build_output_function(
component=self.component,
output_method=output_method,
event_manager=self.component._event_manager,
),
args_schema=args_schema,
event_manager = self.component._event_manager
if asyncio.iscoroutinefunction(output_method):
tools.append(
StructuredTool(
name=formatted_name,
description=build_description(self.component, output),
coroutine=_build_output_async_function(self.component, output_method, event_manager),
args_schema=args_schema,
handle_tool_error=True,
callbacks=callbacks,
)
)
else:
tools.append(
StructuredTool(
name=formatted_name,
description=build_description(self.component, output),
func=_build_output_function(self.component, output_method, event_manager),
args_schema=args_schema,
handle_tool_error=True,
callbacks=callbacks,
)
)
if len(tools) == 1 and (tool_name or tool_description):
tool = tools[0]
tool.name = tool_name or tool.name
tool.description = tool_description or tool.description
elif tool_name or tool_description:
msg = (
"When passing a tool name or description, there must be only one tool, "
f"but {len(tools)} tools were found."
)
raise ValueError(msg)
return tools
1 change: 1 addition & 0 deletions src/backend/base/langflow/base/tools/constants.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
TOOL_OUTPUT_NAME = "component_as_tool"
TOOL_OUTPUT_DISPLAY_NAME = "Toolset"
10 changes: 5 additions & 5 deletions src/backend/base/langflow/components/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,24 @@ class AgentComponent(ToolCallingAgentComponent):
*LCToolsAgentComponent._base_inputs,
*memory_inputs,
]
outputs = [Output(name="response", display_name="Response", method="get_response")]
outputs = [Output(name="response", display_name="Response", method="message_response")]

async def get_response(self) -> Message:
async def message_response(self) -> Message:
llm_model = self.get_llm()
if llm_model is None:
msg = "No language model selected"
raise ValueError(msg)
self.chat_history = self.get_memory_data()

agent = self.set(
self.set(
llm=llm_model,
tools=[self.tools],
chat_history=self.chat_history,
input_value=self.input_value,
system_prompt=self.system_prompt,
)

return await agent.message_response()
agent = self.create_agent_runnable()
return await self.run_agent(agent)

def get_memory_data(self):
memory_kwargs = {
Expand Down
5 changes: 0 additions & 5 deletions src/backend/base/langflow/components/agents/tool_calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ class ToolCallingAgentComponent(LCToolsAgentComponent):
info="Initial instructions and context provided to guide the agent's behavior.",
value="You are a helpful assistant that can use tools to answer questions and perform tasks.",
),
MessageTextInput(
name="input_value",
display_name="Input",
info="The input provided by the user for the agent to process.",
),
DataInput(name="chat_history", display_name="Chat Memory", is_list=True, advanced=True),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CustomComponent(Component):
name = "CustomComponent"

inputs = [
MessageTextInput(name="input_value", display_name="Input Value", value="Hello, World!"),
MessageTextInput(name="input_value", display_name="Input Value", value="Hello, World!", tool_mode=True),
]

outputs = [
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/components/outputs/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def message_response(self) -> Message:
message.sender_name = self.sender_name
message.session_id = self.session_id
message.flow_id = self.graph.flow_id
message.properties.source = Source(id=_source_id, display_name=_display_name, source=_source)
message.properties.source = self._build_source(_source_id, _display_name, _source)
message.properties.icon = _icon
message.properties.background_color = _background_color
message.properties.text_color = _text_color
Expand Down
1 change: 1 addition & 0 deletions src/backend/base/langflow/custom/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ def getattr_return_dict(value):
"outputs": getattr_return_list_of_object,
"inputs": getattr_return_list_of_object,
"metadata": getattr_return_dict,
"tool_mode": getattr_return_bool,
}
Loading
Loading