fix(memory): handle langchain-community SQLChatMessageHistory API rename
CI / push-validation (pull_request) Successful in 34s
CI / helm (pull_request) Successful in 44s
CI / build (pull_request) Successful in 49s
CI / lint (pull_request) Successful in 1m4s
CI / typecheck (pull_request) Failing after 1m5s
CI / quality (pull_request) Successful in 1m6s
CI / security (pull_request) Successful in 1m12s
CI / integration_tests (pull_request) Successful in 4m9s
CI / unit_tests (pull_request) Successful in 6m17s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
CI / push-validation (pull_request) Successful in 34s
CI / helm (pull_request) Successful in 44s
CI / build (pull_request) Successful in 49s
CI / lint (pull_request) Successful in 1m4s
CI / typecheck (pull_request) Failing after 1m5s
CI / quality (pull_request) Successful in 1m6s
CI / security (pull_request) Successful in 1m12s
CI / integration_tests (pull_request) Successful in 4m9s
CI / unit_tests (pull_request) Successful in 6m17s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
langchain-community >= 0.3 renamed connection_string to connection in SQLChatMessageHistory.__init__(). Use the new 'connection' kwarg first and fall back to 'connection_string' for older versions. Also updates the test assertion in memory_service_coverage_steps.py to accept either parameter name. Fixes CI errors in: - plan_service_coverage.feature:128,141 - consolidated_misc.feature:1531
This commit is contained in:
@@ -342,7 +342,10 @@ def step_validate_sql_constructor(context: Any) -> None:
|
||||
assert context.sql_history_calls
|
||||
_, kwargs = context.sql_history_calls[0]
|
||||
assert kwargs["session_id"] == "sql-session"
|
||||
assert kwargs["connection_string"] == context.connection_string
|
||||
actual_connection = kwargs.get("connection") or kwargs.get("connection_string")
|
||||
assert actual_connection == context.connection_string, (
|
||||
f"Expected {context.connection_string}, got {actual_connection}"
|
||||
)
|
||||
assert kwargs.get("table_name") == "message_history"
|
||||
|
||||
|
||||
|
||||
@@ -485,15 +485,26 @@ class MemoryService:
|
||||
# Initialize message history
|
||||
history: BaseChatMessageHistory
|
||||
if connection_string:
|
||||
# Use SQL persistence if connection string provided
|
||||
history = cast(
|
||||
BaseChatMessageHistory,
|
||||
SQLChatMessageHistory(
|
||||
session_id=session_id,
|
||||
connection_string=connection_string,
|
||||
table_name="message_history",
|
||||
),
|
||||
)
|
||||
# Use SQL persistence if connection string provided.
|
||||
# langchain-community >= 0.3 renamed connection_string to connection.
|
||||
try:
|
||||
history = cast(
|
||||
BaseChatMessageHistory,
|
||||
SQLChatMessageHistory(
|
||||
session_id=session_id,
|
||||
connection=connection_string,
|
||||
table_name="message_history",
|
||||
),
|
||||
)
|
||||
except TypeError:
|
||||
history = cast(
|
||||
BaseChatMessageHistory,
|
||||
SQLChatMessageHistory(
|
||||
session_id=session_id,
|
||||
connection_string=connection_string,
|
||||
table_name="message_history",
|
||||
),
|
||||
)
|
||||
else:
|
||||
# Use in-memory storage as fallback
|
||||
history = InMemoryChatMessageHistory()
|
||||
|
||||
Reference in New Issue
Block a user