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

feature: add new playground events #4280

Merged
merged 410 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
410 commits
Select commit Hold shift + click to select a range
3b09d3e
chore: Update editMessageField component to include margin-right for …
anovazzi1 Oct 10, 2024
56a9cb0
Merge branch 'main' into UpdateChatDataSource
ogabrielluiz Oct 11, 2024
312ec21
Merge branch 'main' into UpdateChatDataSource
ogabrielluiz Oct 14, 2024
1a6a3c0
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 14, 2024
a7cc9bd
Update down_revision in Alembic migration script
ogabrielluiz Oct 14, 2024
c99a0e9
Merge branch 'main' into UpdateChatDataSource
ogabrielluiz Oct 14, 2024
c836daf
Refactor IOModal component to simplify session visibility handling
anovazzi1 Oct 14, 2024
40b03bc
Merge branch 'main' into UpdateChatDataSource
ogabrielluiz Oct 14, 2024
f71234a
Add new schema for playground events with various event types
ogabrielluiz Oct 14, 2024
60b926e
Add PlaygroundEvent to LoggableType in log schema
ogabrielluiz Oct 14, 2024
8dca9e1
Add timestamp validation utility to schema utils and refactor Message…
ogabrielluiz Oct 14, 2024
5d0797f
Add custom serialization for datetime and Decimal in data schema
ogabrielluiz Oct 14, 2024
b2e99cc
Add session_id handling to graph and chat API
ogabrielluiz Oct 14, 2024
779786f
Add error handling for event creation in EventManager
ogabrielluiz Oct 14, 2024
eb83f88
Enhance session ID handling in vertex base logic
ogabrielluiz Oct 14, 2024
2ea91b7
Add message handling and streaming capabilities to custom component
ogabrielluiz Oct 14, 2024
2e79c78
Add new schema types and properties for chat and messages components
ogabrielluiz Oct 14, 2024
540b2c5
Add customizable chat message styles and icons in IOModal component
ogabrielluiz Oct 14, 2024
3a880e2
Add support for handling Playground events in chat view
ogabrielluiz Oct 14, 2024
6cf252c
merge branch main
anovazzi1 Oct 22, 2024
e990b84
revert changes made to bypass ruff-check
anovazzi1 Oct 22, 2024
e45dc64
revert changes made to bypass ruff-check
anovazzi1 Oct 22, 2024
74d71b3
Refactor file parsing logic in ChatView component
anovazzi1 Oct 22, 2024
167ac23
fix ui problem
anovazzi1 Oct 23, 2024
29e15de
Refactor feature flags and chat view components
anovazzi1 Oct 23, 2024
62c48a7
Refactor IOModal newModal component styles
anovazzi1 Oct 23, 2024
03bf7b0
Refactor styles in EditMessageField and ChatMessage components
anovazzi1 Oct 23, 2024
fb5e3c3
Refactor styles in EditMessageField component
anovazzi1 Oct 23, 2024
544be28
Refactor styles in ChatMessage component to fix UI problem
anovazzi1 Oct 23, 2024
32e1285
Refactor styles in UploadFileButton component and add image attachmen…
anovazzi1 Oct 23, 2024
311682d
Refactor styles in ChatCodeTabComponent to update language text color
anovazzi1 Oct 23, 2024
ca78723
fix padding in other field views
anovazzi1 Oct 23, 2024
cd1472e
Refactor styles in ChatComponent and add tooltip to the playground
anovazzi1 Oct 23, 2024
edbde0c
Refactor styles in constants.ts to remove unused input and output types
anovazzi1 Oct 23, 2024
295bdf0
Merge remote-tracking branch 'origin' into add-new-schema
anovazzi1 Oct 23, 2024
1de0717
Merge remote-tracking branch 'origin/main' into add-new-schema
anovazzi1 Oct 23, 2024
f29b867
Refactor session selector styles
anovazzi1 Oct 23, 2024
f166f03
Refactor chatView component styles
anovazzi1 Oct 23, 2024
2603b82
update colors to use variables
anovazzi1 Oct 23, 2024
7b6c195
Refactor code tab component and update code styling
anovazzi1 Oct 23, 2024
183cd79
Refactor buttonSendWrapper component styles
anovazzi1 Oct 23, 2024
3f7cdfb
update colors to use variables
anovazzi1 Oct 23, 2024
2521687
update colors to use variables
anovazzi1 Oct 23, 2024
8f91aef
Refactor chatComponent and chatInput styles
anovazzi1 Oct 23, 2024
f4bd595
update colors to use variables
anovazzi1 Oct 23, 2024
924ca66
chore: add new attributes to model definition
italojohnny Oct 24, 2024
5ab0b67
chore: generate database migration
italojohnny Oct 24, 2024
719a27e
chore: add MetaData and ContentBlock models and update Message schema
italojohnny Oct 24, 2024
23475ba
chore: add error handling to build_results and adjust message event h…
italojohnny Oct 24, 2024
93b68e8
chore: deserialize meta_data and content_blocks fields in add_message…
italojohnny Oct 24, 2024
ac40985
raw
italojohnny Oct 24, 2024
3825ed9
Refactor message and chat types to include category, meta_data, and c…
anovazzi1 Oct 24, 2024
a20a75f
raw
italojohnny Oct 24, 2024
0d44d7e
Refactor error handling in component.py and newChatMessage.tsx
anovazzi1 Oct 24, 2024
0747d38
add source to bot messages
anovazzi1 Oct 24, 2024
4afe187
raw
italojohnny Oct 24, 2024
6fee429
Refactor chatMessage component to include meta_data icon and source
anovazzi1 Oct 24, 2024
0772f9c
improve icon, background color, text color handling in chat message
anovazzi1 Oct 24, 2024
00081c2
add edit flag correctly
anovazzi1 Oct 24, 2024
927b048
use svg icon logo instead of chain emoji
anovazzi1 Oct 28, 2024
d7a6680
add text effect
anovazzi1 Oct 28, 2024
eb8a170
update error colors
anovazzi1 Oct 28, 2024
7c0d0f5
fix error aligment
anovazzi1 Oct 28, 2024
15cece8
add text shimmer effect
anovazzi1 Oct 28, 2024
9cdfdbf
improve is running style
anovazzi1 Oct 28, 2024
e758baa
Add support for importing SVG files in Vite environment
anovazzi1 Oct 28, 2024
7ca60e1
Add chatLogoIcon component with Chain logo
anovazzi1 Oct 28, 2024
a731a3d
Refactor chat message component to use chatLogoIcon component
anovazzi1 Oct 28, 2024
07f46b0
Refactor chatView component to use chatLogoIcon component
anovazzi1 Oct 28, 2024
aef1ce6
remove from empty chat
anovazzi1 Oct 28, 2024
d685121
update text sizes and style
anovazzi1 Oct 28, 2024
7c5f1d6
remove icon in message logs
anovazzi1 Oct 28, 2024
d446be9
fix stop button color
anovazzi1 Oct 28, 2024
a495cc5
update background color and sender name size
anovazzi1 Oct 28, 2024
6e1b67e
prevent list index out of range error
anovazzi1 Oct 28, 2024
c97f333
Fix onBlur event in EditMessageField component
anovazzi1 Oct 28, 2024
0147874
improve edit message field
anovazzi1 Oct 28, 2024
d9faa83
improve edit background behaviour
anovazzi1 Oct 28, 2024
fd4a0f8
Update chat input styling for better user experience
anovazzi1 Oct 28, 2024
821a486
Refactor ChatCodeTabComponent to remove redundant "Copy" text in button
anovazzi1 Oct 28, 2024
139fd89
Refactor code to use CSS variables for background color in code blocks
anovazzi1 Oct 29, 2024
df51a14
Refactor ChatCodeTabComponent to update code block styling
anovazzi1 Oct 29, 2024
e825b31
Refactor code to update code block styling and improve chat input sty…
anovazzi1 Oct 29, 2024
39217db
prevent Flow Running after error rendering
anovazzi1 Oct 29, 2024
9a459b8
Refactor code to add IOModalOpen state and setter function
anovazzi1 Oct 29, 2024
fe173f8
Refactor code to add IOModalOpen state and setter function
anovazzi1 Oct 29, 2024
fba3448
Refactor code to remove console.log statement
anovazzi1 Oct 29, 2024
f071f08
update icon and padding
anovazzi1 Oct 29, 2024
f35194c
Refactor code to retrieve connected model name in ChatComponent
anovazzi1 Oct 29, 2024
c5ebafb
Merge branch 'main' into add-new-schema
ogabrielluiz Oct 29, 2024
f7e4ded
run formatter
ogabrielluiz Oct 29, 2024
4b0fa08
fix stop button glitch
anovazzi1 Oct 29, 2024
8e38823
update max width
anovazzi1 Oct 30, 2024
405cf3b
Refactor GithubStarButton component to handle null value for stars
anovazzi1 Oct 30, 2024
e560424
Refactor tailwind.config.mjs to add utility classes for fading text t…
anovazzi1 Oct 30, 2024
bc17216
improve faded truncate function
anovazzi1 Oct 30, 2024
40f8153
Refactor ChatView component to handle null value for chat history cat…
anovazzi1 Oct 30, 2024
b4b99f8
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
983a970
Refactor DialogContent component to improve close button styling
anovazzi1 Oct 30, 2024
78e18fd
Refactor IOModal component to improve sidebar behavior and styling
anovazzi1 Oct 30, 2024
bf002c8
Refactor ChatView component to remove unused code and improve perform…
anovazzi1 Oct 30, 2024
c56167e
Refactor session selector component to add tooltip for options
anovazzi1 Oct 30, 2024
f7fb681
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
6e8622e
update several icon sizes and hover states
anovazzi1 Oct 30, 2024
bdf2539
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
ba26992
Refactor IOModal component to improve sidebar behavior and styling
anovazzi1 Oct 30, 2024
7423a1d
Refactor IOModal component to handle sidebar behavior on window resize
anovazzi1 Oct 30, 2024
21d90c3
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
faa2c73
fix error related to content blocks being null
anovazzi1 Oct 30, 2024
d3b5a2b
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
9d5033f
add component id as sender to the message
anovazzi1 Oct 30, 2024
aead120
add component id as source to the message
anovazzi1 Oct 30, 2024
fc066ce
Add fitViewNode function to FlowStoreType
anovazzi1 Oct 30, 2024
6bd0084
enable closing chat on error message
anovazzi1 Oct 30, 2024
f6c9b12
Add ClickableLinks component for rendering clickable URLs in chat mes…
anovazzi1 Oct 30, 2024
b03c958
add error message transition
anovazzi1 Oct 30, 2024
e985fef
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
9510878
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Oct 30, 2024
82edd72
use IsPlayground flag
anovazzi1 Oct 30, 2024
1ce5dc1
Remove console.log statement in setIOModalOpen function
anovazzi1 Oct 30, 2024
2f416c3
update max-w
anovazzi1 Oct 30, 2024
b1566b5
prevent breaking the buttons on small screen
anovazzi1 Oct 30, 2024
7cfa536
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
178bdcb
remove underline when component is not clicable
anovazzi1 Oct 30, 2024
1fd7ee1
Refactor IOModal component to remove unnecessary props and update usage
anovazzi1 Oct 30, 2024
ae9d5ef
fix html missing closing tag error
anovazzi1 Oct 30, 2024
d2addbf
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
40db6aa
Refactor PlaygroundPage component to improve flow initialization and …
anovazzi1 Oct 30, 2024
12986aa
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2024
8a16bd1
Refactor cardComponent and storeCardComponent to comment out playgrou…
anovazzi1 Oct 30, 2024
e8ec013
Refactor message model to replace 'meta_data' with 'properties' and u…
ogabrielluiz Oct 30, 2024
c4c2033
Add new schema for content types with Pydantic models
ogabrielluiz Oct 30, 2024
0c807b8
Add ContentBlock schema with support for multiple content types
ogabrielluiz Oct 30, 2024
34b8dc1
Refactor: Import ContentBlock from langflow.schema.content_block inst…
ogabrielluiz Oct 30, 2024
635d206
Add SendMessageFunctionType protocol to log schema for message handling
ogabrielluiz Oct 30, 2024
8c66b92
Refactor chat message model to replace 'meta_data' with 'properties' …
ogabrielluiz Oct 30, 2024
c486308
Add ContentBlock import and enhance send_message method in component.py
ogabrielluiz Oct 30, 2024
fc2bdeb
Add async on_chain_start method to callback for logging chain start e…
ogabrielluiz Oct 30, 2024
e70000f
Refactor add_messagetables function to replace 'meta_data' with 'prop…
ogabrielluiz Oct 30, 2024
754ffbe
Fix typo in 'traceback' property name in ErrorDetails interface
ogabrielluiz Oct 30, 2024
c05274c
Add condition to check chat history length before rendering chat lock
ogabrielluiz Oct 30, 2024
ce59b07
Refactor error content structure and enhance message event handling
ogabrielluiz Oct 30, 2024
d9145fd
Add `update_messages` function to handle message updates in memory mo…
ogabrielluiz Oct 30, 2024
896b200
Add check for 'id' attribute in stored_message for message validation
ogabrielluiz Oct 30, 2024
9940680
Add new content types and TypeAlias for schema in content_types.py
ogabrielluiz Oct 30, 2024
3118eff
Add custom serialization for UUID and BaseModel types in data schema
ogabrielluiz Oct 30, 2024
32a27c3
Refactor `ContentType` to use `ContentTypes` union and update `conten…
ogabrielluiz Oct 30, 2024
c76ec8e
Update model to use specific types for properties and content_blocks …
ogabrielluiz Oct 30, 2024
66ff753
Change return type of 'serialize_params' method to string
ogabrielluiz Oct 30, 2024
d649683
Add sender fields and properties handling to PlaygroundEvent and crea…
ogabrielluiz Oct 30, 2024
06be69b
Refactor chat message component to use 'properties' instead of 'meta_…
ogabrielluiz Oct 30, 2024
7f826ad
Refactor message handling to improve error categorization and session…
ogabrielluiz Oct 30, 2024
d5bc7ad
Enhance ContentBlock initialization to update model fields with defaults
ogabrielluiz Oct 30, 2024
a0621a3
Add new content types and update ContentBlock interface in chat types
ogabrielluiz Oct 30, 2024
b2b3c3e
Refactor error handling in chat messages to use `ErrorContent` type
ogabrielluiz Oct 30, 2024
2b2d397
Add ErrorMessage class for handling error-specific messages in schema
ogabrielluiz Oct 31, 2024
6e7d0cc
Add type annotations for cache and logs in custom_component.py
ogabrielluiz Oct 31, 2024
2a4b372
Refactor error handling in custom component to use `send_error` method
ogabrielluiz Oct 31, 2024
660c901
Merge branch 'main' into add-new-schema
ogabrielluiz Oct 31, 2024
1e12bcd
Add customizable properties for chat components
ogabrielluiz Oct 31, 2024
63c8665
Merge branch 'main' into add-new-schema
ogabrielluiz Oct 31, 2024
a55dca3
Add 'category' field to MessageEvent and update create_message function
ogabrielluiz Oct 31, 2024
00c9fad
Remove unused message handling methods from ChatComponent
ogabrielluiz Oct 31, 2024
d5b2f10
Refactor message event handling in chat module
ogabrielluiz Oct 31, 2024
2ec651f
Add 'category' field to Message creation and pass 'id_' in _send_mess…
ogabrielluiz Oct 31, 2024
cac6c19
Add 'category' field with Literal type to Message schema and default …
ogabrielluiz Oct 31, 2024
531c716
Refactor message event handling in chat module
anovazzi1 Oct 31, 2024
99cfdf0
Refactor buttonSendWrapper component to add data-testid attribute
anovazzi1 Oct 31, 2024
12d9fbc
Refactor ChatComponent to replace 'store_message' with 'send_message'…
ogabrielluiz Oct 31, 2024
4711595
refactor: streamline message handling in Component
ogabrielluiz Oct 31, 2024
2e891d3
feat: Update input handling and output storage for chat components
ogabrielluiz Oct 31, 2024
ee2a1fd
Ensure 'id' field is set in message data dictionary if not present
ogabrielluiz Oct 31, 2024
ce206ec
refactor: Simplify property retrieval from source component in ChatCo…
ogabrielluiz Oct 31, 2024
c7b23dc
refactor: Replace property retrieval logic with a dedicated method in…
ogabrielluiz Oct 31, 2024
81b898b
Refactor `TokenEvent` class and add `timestamp` field with default fa…
ogabrielluiz Oct 31, 2024
64bdad6
refactor: Simplify message processing by removing unused parameters i…
ogabrielluiz Oct 31, 2024
a1513ec
Refactor message text update logic in messagesStore
anovazzi1 Oct 31, 2024
82879bc
Refactor border styling in ChatInput component
anovazzi1 Oct 31, 2024
9893505
refactor: Consolidate properties handling in PlaygroundEvent and crea…
ogabrielluiz Oct 31, 2024
67f82c9
refactor: Update timestamp formatting to include timezone information…
ogabrielluiz Oct 31, 2024
e028ef6
refactor: Add StreamingError exception for better error handling in s…
ogabrielluiz Oct 31, 2024
7760980
refactor: Add source_display_name attribute to Properties model for e…
ogabrielluiz Oct 31, 2024
fe0cb86
refactor: Enhance ChatComponent to return source display name and upd…
ogabrielluiz Oct 31, 2024
1a1ae7c
refactor: Improve error handling in Component class and enhance creat…
ogabrielluiz Oct 31, 2024
33e1369
feat: enhance ChatOutput component for improved message handling
ogabrielluiz Oct 31, 2024
65a5372
feat: add delete_message function to remove messages by ID from the m…
ogabrielluiz Oct 31, 2024
67bb878
Add error handling for message streaming and implement message deleti…
ogabrielluiz Oct 31, 2024
b8e0488
feat: Enhance message streaming and event handling
ogabrielluiz Oct 31, 2024
e9a83d2
improve UI
anovazzi1 Oct 31, 2024
f519b40
Refactor buttonSendWrapper component to add data-testid attribute and…
anovazzi1 Oct 31, 2024
9f62f1f
fix edited tag
anovazzi1 Nov 1, 2024
51774f2
add tooltip to add button
anovazzi1 Nov 1, 2024
68fca74
Merge remote-tracking branch 'origin/main' into add-new-schema
anovazzi1 Nov 1, 2024
d4a5247
fix bug after merge
anovazzi1 Nov 1, 2024
58e25a7
update examples
anovazzi1 Nov 1, 2024
91c6fc1
updateinput without chat
anovazzi1 Nov 1, 2024
d271e75
fix some frontend tests
anovazzi1 Nov 1, 2024
3af17e6
fix test
anovazzi1 Nov 1, 2024
0233c15
update test
anovazzi1 Nov 1, 2024
e444ea4
Update fileUploadComponent.spec.ts to fix test and update input witho…
anovazzi1 Nov 1, 2024
8130bde
refactor event creation functions and enhance ErrorEvent structure
ogabrielluiz Nov 1, 2024
9bd38e3
refactor ErrorMessage to use Source for sender and component details
ogabrielluiz Nov 1, 2024
c3f0664
refactor Properties to use Source model for source details and add va…
ogabrielluiz Nov 1, 2024
ce04630
refactor ChatMessage component for improved readability and structure
ogabrielluiz Nov 1, 2024
d911fa1
refactor ChatMessageType to use PropertiesType for improved structure…
ogabrielluiz Nov 1, 2024
a1cb7eb
Add Source ID to message properties and update exception handling
ogabrielluiz Nov 1, 2024
78aa354
Add 'Source' property to error handling in custom_component module
ogabrielluiz Nov 1, 2024
20ff0bd
Enhance event ID generation with event type prefix in `send_event` me…
ogabrielluiz Nov 1, 2024
4d5b0fc
Refactor ChatOutput class to use Properties and Source schemas for me…
ogabrielluiz Nov 1, 2024
f186a25
update style in tailwind and add fallback for nullable values
anovazzi1 Nov 1, 2024
6c0fc7d
fix playground test
anovazzi1 Nov 1, 2024
fd57272
Update message handling in Component class to send modified message c…
ogabrielluiz Nov 1, 2024
a75d43a
Add flow_id and session_id to ErrorEvent creation function
ogabrielluiz Nov 1, 2024
7c3c167
Update content_blocks initialization and add flow_id parameter to Err…
ogabrielluiz Nov 1, 2024
e47aaa0
feat: include vertex ID in class instantiation
ogabrielluiz Nov 1, 2024
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
3ba3f13
skip tests
anovazzi1 Nov 4, 2024
f016fd7
Merge branch 'main' into add-new-schema
ogabrielluiz Nov 4, 2024
57e4724
skip tests
anovazzi1 Nov 4, 2024
286f153
Merge branch 'main' into add-new-schema
anovazzi1 Nov 4, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""event_error

Revision ID: 1eab2c3eb45e
Revises: eb5e72293a8e
Create Date: 2024-10-24 12:03:24.118937

"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import sqlite
from sqlalchemy.engine.reflection import Inspector

# revision identifiers, used by Alembic.
revision: str = '1eab2c3eb45e'
down_revision: Union[str, None] = 'eb5e72293a8e'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
conn = op.get_bind()
inspector = Inspector.from_engine(conn) # type: ignore
table_names = inspector.get_table_names() # noqa
column_names = [column["name"] for column in inspector.get_columns("message")]
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('message', schema=None) as batch_op:
if "properties" not in column_names:
batch_op.add_column(sa.Column('properties', sa.JSON(), nullable=True))
if "category" not in column_names:
batch_op.add_column(sa.Column('category', sa.Text(), nullable=True))
if "content_blocks" not in column_names:
batch_op.add_column(sa.Column('content_blocks', sa.JSON(), nullable=True))

# ### end Alembic commands ###


def downgrade() -> None:
conn = op.get_bind()
inspector = Inspector.from_engine(conn) # type: ignore
table_names = inspector.get_table_names() # noqa
column_names = [column["name"] for column in inspector.get_columns("message")]
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('message', schema=None) as batch_op:
if "content_blocks" in column_names:
batch_op.drop_column('content_blocks')
if "category" in column_names:
batch_op.drop_column('category')
if "properties" in column_names:
batch_op.drop_column('properties')

# ### end Alembic commands ###
3 changes: 3 additions & 0 deletions src/backend/base/langflow/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ async def build_graph_and_get_order() -> tuple[list[str], list[str], Graph]:
else:
first_layer = graph.sort_vertices()

if inputs is not None and hasattr(inputs, "session") and inputs.session is not None:
graph.session_id = inputs.session

for vertex_id in first_layer:
graph.run_manager.add_to_vertices_being_run(vertex_id)

Expand Down
27 changes: 27 additions & 0 deletions src/backend/base/langflow/base/agents/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ class AgentAsyncHandler(AsyncCallbackHandler):
def __init__(self, log_function: LogFunctionType | None = None):
self.log_function = log_function

async def on_chain_start(
self,
serialized: dict[str, Any],
inputs: dict[str, Any],
*,
run_id: UUID,
parent_run_id: UUID | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) -> None:
if self.log_function is None:
return
self.log_function(
{
"type": "chain_start",
"serialized": serialized,
"inputs": inputs,
"run_id": run_id,
"parent_run_id": parent_run_id,
"tags": tags,
"metadata": metadata,
**kwargs,
},
name="Chain Start",
)

async def on_tool_start(
self,
serialized: dict[str, Any],
Expand Down
97 changes: 24 additions & 73 deletions src/backend/base/langflow/base/io/chat.py
Original file line number Diff line number Diff line change
@@ -1,86 +1,15 @@
from collections.abc import AsyncIterator, Iterator
from typing import cast

from langflow.custom import Component
from langflow.memory import store_message
from langflow.schema import Data
from langflow.schema.message import Message
from langflow.services.database.models.message.crud import update_message
from langflow.utils.async_helpers import run_until_complete


class ChatComponent(Component):
display_name = "Chat Component"
description = "Use as base for chat components."

def store_message(self, message: Message) -> Message:
messages = store_message(message, flow_id=self.graph.flow_id)
if len(messages) != 1:
msg = "Only one message can be stored at a time."
raise ValueError(msg)

stored_message = messages[0]
self._send_message_event(stored_message)

if self._should_stream_message(stored_message, message):
complete_message = self._stream_message(message, stored_message.id)
stored_message = self._update_stored_message(stored_message.id, complete_message)

self.status = stored_message
return stored_message

def _send_message_event(self, message: Message) -> None:
if hasattr(self, "_event_manager") and self._event_manager:
self._event_manager.on_message(data=message.data)

def _should_stream_message(self, stored_message: Message, original_message: Message) -> bool:
return bool(
hasattr(self, "_event_manager")
and self._event_manager
and stored_message.id
and not isinstance(original_message.text, str)
)

def _update_stored_message(self, message_id: str, complete_message: str) -> Message:
message_table = update_message(message_id=message_id, message={"text": complete_message})
updated_message = Message(**message_table.model_dump())
self.vertex.added_message = updated_message
return updated_message

def _process_chunk(self, chunk: str, complete_message: str, message: Message, message_id: str) -> str:
complete_message += chunk
if self._event_manager:
self._event_manager.on_token(
data={
"text": complete_message,
"chunk": chunk,
"sender": message.sender,
"sender_name": message.sender_name,
"id": str(message_id),
}
)
return complete_message

async def _handle_async_iterator(self, iterator: AsyncIterator, message: Message, message_id: str) -> str:
complete_message = ""
async for chunk in iterator:
complete_message = self._process_chunk(chunk.content, complete_message, message, message_id)
return complete_message

def _stream_message(self, message: Message, message_id: str) -> str:
iterator = message.text
if not isinstance(iterator, AsyncIterator | Iterator):
msg = "The message must be an iterator or an async iterator."
raise TypeError(msg)

if isinstance(iterator, AsyncIterator):
return run_until_complete(self._handle_async_iterator(iterator, message, message_id))

complete_message = ""
for chunk in iterator:
complete_message = self._process_chunk(chunk.content, complete_message, message, message_id)
return complete_message

def build_with_data(
self,
*,
Expand All @@ -105,9 +34,31 @@ def build_with_data(
def _create_message(self, input_value, sender, sender_name, files, session_id) -> Message:
if isinstance(input_value, Data):
return Message.from_data(input_value)
return Message(text=input_value, sender=sender, sender_name=sender_name, files=files, session_id=session_id)
return Message(
text=input_value,
sender=sender,
sender_name=sender_name,
files=files,
session_id=session_id,
category="message",
)

def _send_messages_events(self, messages) -> None:
if hasattr(self, "_event_manager") and self._event_manager:
for stored_message in messages:
self._event_manager.on_message(data=stored_message.data)
id_ = stored_message.id
self._send_message_event(message=stored_message, id_=id_)

def get_properties_from_source_component(self):
if self.vertex.incoming_edges:
source_id = self.vertex.incoming_edges[0].source_id
_source_vertex = self.graph.get_vertex(source_id)
component = _source_vertex.custom_component
source = component.display_name
icon = component.icon
possible_attributes = ["model_name", "model_id", "model"]
for attribute in possible_attributes:
if hasattr(component, attribute) and getattr(component, attribute):
return getattr(component, attribute), icon, source, component._id
return source, icon, component.display_name, component._id
return None, None, None, None
24 changes: 23 additions & 1 deletion src/backend/base/langflow/components/inputs/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,43 @@ class ChatInput(ChatComponent):
advanced=True,
is_list=True,
),
MessageTextInput(
name="background_color",
display_name="Background Color",
info="The background color of the icon.",
advanced=True,
),
MessageTextInput(
name="chat_icon",
display_name="Icon",
info="The icon of the message.",
advanced=True,
),
MessageTextInput(
name="text_color",
display_name="Text Color",
info="The text color of the name",
advanced=True,
),
]
outputs = [
Output(display_name="Message", name="message", method="message_response"),
]

def message_response(self) -> Message:
_background_color = self.background_color
_text_color = self.text_color
_icon = self.chat_icon
message = Message(
text=self.input_value,
sender=self.sender,
sender_name=self.sender_name,
session_id=self.session_id,
files=self.files,
properties={"background_color": _background_color, "text_color": _text_color, "icon": _icon},
)
if self.session_id and isinstance(message, Message) and self.should_store_message:
stored_message = self.store_message(
stored_message = self.send_message(
message,
)
self.message.value = stored_message
Expand Down
49 changes: 47 additions & 2 deletions src/backend/base/langflow/components/outputs/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from langflow.inputs import BoolInput
from langflow.io import DropdownInput, MessageTextInput, Output
from langflow.schema.message import Message
from langflow.schema.properties import Properties, Source
from langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_NAME_AI, MESSAGE_SENDER_USER


Expand Down Expand Up @@ -52,20 +53,64 @@ class ChatOutput(ChatComponent):
advanced=True,
info="Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.",
),
MessageTextInput(
name="background_color",
display_name="Background Color",
info="The background color of the icon.",
advanced=True,
),
MessageTextInput(
name="chat_icon",
display_name="Icon",
info="The icon of the message.",
advanced=True,
),
MessageTextInput(
name="text_color",
display_name="Text Color",
info="The text color of the name",
advanced=True,
),
]
outputs = [
Output(display_name="Message", name="message", method="message_response"),
Output(
display_name="Message",
name="message",
method="message_response",
),
]

def _build_source(self, _id: str | None, display_name: str | None, source: str | None) -> Source:
source_dict = {}
if _id:
source_dict["id"] = _id
if display_name:
source_dict["display_name"] = display_name
if source:
source_dict["source"] = source
return Source(**source_dict)

def message_response(self) -> Message:
_source, _icon, _display_name, _source_id = self.get_properties_from_source_component()
_background_color = self.background_color
_text_color = self.text_color
if self.chat_icon:
_icon = self.chat_icon
message = Message(
text=self.input_value,
sender=self.sender,
sender_name=self.sender_name,
session_id=self.session_id,
flow_id=self.graph.flow_id,
properties=Properties(
source=self._build_source(_source_id, _display_name, _source),
icon=_icon,
background_color=_background_color,
text_color=_text_color,
),
)
if self.session_id and isinstance(message, Message) and self.should_store_message:
stored_message = self.store_message(
stored_message = self.send_message(
message,
)
self.message.value = stored_message
Expand Down
Loading
Loading