mirror of
https://github.com/langgenius/dify.git
synced 2026-06-24 13:01:16 +08:00
Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: L1nSn0w <l1nsn0w@qq.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Stephen Zhou <hi@hyoban.cc> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: wangxiaolei <fatelei@gmail.com>
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
|