mirror of
https://github.com/langgenius/dify.git
synced 2026-07-15 17:37:38 +08:00
- ReasoningPanel: derive text inline instead of useMemo([content]); the live stream mutates the reasoningContent object in place under a stable reference, so a content-keyed memo froze the panel after the first delta. Add a test that re-renders with the same mutated object to lock in streaming. - Explore/installed-app message API: add ExploreMessageListItem + ExploreMessageInfiniteScrollPagination so message_metadata (incl. reasoning) is surfaced, letting chat-with-history rehydrate the thinking panel on reload. Base MessageListItem / service_api public contract left unchanged. - Persist reasoning per LLM node by accumulating across iteration/loop passes (append, not overwrite) to match the live stream; guard on isinstance(str).
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
from fields.message_fields import ExploreMessageListItem, MessageListItem
|
|
|
|
|
|
def _base_kwargs():
|
|
return {
|
|
"id": "m1",
|
|
"conversation_id": "c1",
|
|
"inputs": {},
|
|
"query": "hi",
|
|
"answer": "answer",
|
|
"retriever_resources": [],
|
|
"agent_thoughts": [],
|
|
"message_files": [],
|
|
"status": "normal",
|
|
"extra_contents": [],
|
|
}
|
|
|
|
|
|
class TestExploreMessageListItem:
|
|
def test_exposes_metadata_for_history_rehydration(self):
|
|
# The Explore/installed-app surface must surface message_metadata (incl. reasoning)
|
|
# so the chat-with-history client can rehydrate the thinking panel on reload.
|
|
item = ExploreMessageListItem(**_base_kwargs(), metadata={"reasoning": {"llm": "thinking..."}})
|
|
|
|
payload = item.model_dump(mode="json")
|
|
|
|
assert payload["metadata"] == {"reasoning": {"llm": "thinking..."}}
|
|
|
|
def test_metadata_defaults_to_none(self):
|
|
item = ExploreMessageListItem(**_base_kwargs())
|
|
assert item.model_dump(mode="json")["metadata"] is None
|
|
|
|
def test_base_message_list_item_has_no_metadata(self):
|
|
# Guard the public service-API contract: the base item must not leak metadata.
|
|
payload = MessageListItem(**_base_kwargs()).model_dump(mode="json")
|
|
assert "metadata" not in payload
|