feat: Update SQLModel dependency and improve UUID handling (#4891)
* Update sqlmodel dependency to version 0.0.20 in pyproject.toml * Handle UUID conversion for message IDs in memory update logic * Refactor Alembic migrations to use `sa.inspect` and update GUID to Uuid type * refactor: Change flow_id parameter type from str to uuid.UUID in graph building functions * refactor: Ensure UUID handling for flow_id and user_id across various services and models * refactor: improve UUID handling and graph caching for compatibility with sqlmodel 0.0.20 * fix: update message assertion in component events test * chore: update sqlmodel dependency to version 0.0.22 in uv.lock and pyproject.toml * fix: enhance flow_id validation to ensure valid UUID format in MessageBase model * fix: add error handling for cache directory cleanup * refactor: improve flow_id type handling in message storage * refactor: enhance flow_id handling in message functions to support UUID type * refactor: integrate Properties into message creation in component event tests * update test durations * fix: correct flow_id parameter in database query * refactor: update session_id and flow_id parameters to support UUID type across message handling functions and models * fix: handle message data update in SQLModel update method * refactor: improve flow_id assignment in message update method to enhance UUID handling
This commit is contained in:
parent
4cc336fa45
commit
3de42f4575
55 changed files with 1035 additions and 898 deletions
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import time
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
from langflow.custom.custom_component.component import Component
|
||||
|
|
@ -9,7 +10,7 @@ from langflow.events.event_manager import EventManager
|
|||
from langflow.schema.content_block import ContentBlock
|
||||
from langflow.schema.content_types import TextContent, ToolContent
|
||||
from langflow.schema.message import Message
|
||||
from langflow.schema.properties import Source
|
||||
from langflow.schema.properties import Properties, Source
|
||||
from langflow.template.field.base import Output
|
||||
|
||||
|
||||
|
|
@ -52,11 +53,13 @@ async def test_component_message_sending():
|
|||
component.set_event_manager(event_manager)
|
||||
|
||||
# Create a message
|
||||
properties = Properties()
|
||||
message = Message(
|
||||
sender="test_sender",
|
||||
session_id="test_session",
|
||||
sender_name="test_sender_name",
|
||||
content_blocks=[ContentBlock(title="Test Block", contents=[TextContent(type="text", text="Test message")])],
|
||||
properties=properties,
|
||||
)
|
||||
|
||||
# Send the message
|
||||
|
|
@ -80,6 +83,7 @@ async def test_component_tool_output():
|
|||
component.set_event_manager(event_manager)
|
||||
|
||||
# Create a message with tool content
|
||||
properties = Properties()
|
||||
message = Message(
|
||||
sender="test_sender",
|
||||
session_id="test_session",
|
||||
|
|
@ -90,6 +94,7 @@ async def test_component_tool_output():
|
|||
contents=[ToolContent(type="tool_use", name="test_tool", tool_input={"query": "test input"})],
|
||||
)
|
||||
],
|
||||
properties=properties,
|
||||
)
|
||||
|
||||
# Send the message
|
||||
|
|
@ -210,7 +215,7 @@ async def test_component_streaming_message():
|
|||
# Create a proper mock vertex with graph and flow_id
|
||||
vertex = MagicMock()
|
||||
mock_graph = MagicMock()
|
||||
mock_graph.flow_id = "12345678-1234-5678-1234-567812345678" # Valid UUID string
|
||||
mock_graph.flow_id = str(uuid4())
|
||||
vertex.graph = mock_graph
|
||||
|
||||
component = ComponentForTesting(_vertex=vertex)
|
||||
|
|
@ -227,11 +232,13 @@ async def test_component_streaming_message():
|
|||
yield StreamChunk(chunk)
|
||||
|
||||
# Create a streaming message
|
||||
properties = Properties()
|
||||
message = Message(
|
||||
sender="test_sender",
|
||||
session_id="test_session",
|
||||
sender_name="test_sender_name",
|
||||
text=text_generator(),
|
||||
properties=properties,
|
||||
)
|
||||
|
||||
# Send the streaming message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue