Skip to content

Commit 9897a3e

Browse files
style: ruff autofix (auto)
1 parent 349f242 commit 9897a3e

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

src/agent.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def _stream_error_chunk(message: str, response_id: str | None = None) -> bytes:
112112
payload["response_id"] = response_id
113113
return (json.dumps(payload) + "\n").encode("utf-8")
114114

115+
115116
async def get_user_conversations(user_id: str):
116117
"""Get conversation metadata for a user from persistent storage."""
117118
return await conversation_persistence.get_user_conversations(user_id)
@@ -163,9 +164,7 @@ async def store_conversation_thread(user_id: str, response_id: str, conversation
163164
content = first_user_msg.get("content", "")
164165
title = content[:50] + "..." if len(content) > 50 else content
165166

166-
user_assistant_messages = [
167-
msg for msg in messages if msg.get("role") in ["user", "assistant"]
168-
]
167+
user_assistant_messages = [msg for msg in messages if msg.get("role") in ["user", "assistant"]]
169168
metadata_only = {
170169
"response_id": response_id,
171170
"title": title,

src/services/chat_service.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,7 @@ async def get_langflow_history(self, user_id: str):
843843
]
844844

845845
if response_id in listed_ids:
846-
existing = next(
847-
c for c in all_conversations if c["response_id"] == response_id
848-
)
846+
existing = next(c for c in all_conversations if c["response_id"] == response_id)
849847
if len(messages) > len(existing.get("messages") or []):
850848
existing["messages"] = messages
851849
existing["total_messages"] = len(messages)
@@ -864,9 +862,7 @@ async def get_langflow_history(self, user_id: str):
864862
else "New Chat"
865863
)
866864
created_at = metadata.get("created_at") or conversation_state.get("created_at")
867-
last_activity = metadata.get("last_activity") or conversation_state.get(
868-
"last_activity"
869-
)
865+
last_activity = metadata.get("last_activity") or conversation_state.get("last_activity")
870866
all_conversations.append(
871867
{
872868
"response_id": response_id,

tests/unit/test_langflow_stream_provider_errors.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ async def raise_provider_error(*_args, **_kwargs) -> AsyncIterator[bytes]:
206206

207207

208208
@pytest.mark.asyncio
209-
async def test_langflow_follow_up_after_error_reuses_store_id(
210-
monkeypatch, store_in_memory
211-
):
209+
async def test_langflow_follow_up_after_error_reuses_store_id(monkeypatch, store_in_memory):
212210
"""Retrying in the same chat must not create a second sidebar conversation."""
213211
provider_message = "Rate limit exceeded for watsonx.ai."
214212
stream_calls: list[dict] = []
@@ -263,9 +261,7 @@ async def raise_provider_error(*_args, **kwargs) -> AsyncIterator[bytes]:
263261

264262

265263
@pytest.mark.asyncio
266-
async def test_langflow_follow_up_ignores_broken_previous_response_id(
267-
monkeypatch, store_in_memory
268-
):
264+
async def test_langflow_follow_up_ignores_broken_previous_response_id(monkeypatch, store_in_memory):
269265
"""Even if the client still sends a failed Langflow session id, do not chain it."""
270266
provider_message = "Invalid API key for Anthropic. Check your credentials."
271267
stream_calls: list[dict] = []

0 commit comments

Comments
 (0)