mirror of
https://github.com/langgenius/dify.git
synced 2026-09-05 08:48:10 +08:00
Merge 38118aff07 into 8031ea6d73
This commit is contained in:
commit
f97903c0a0
@ -1114,9 +1114,6 @@ class AdvancedChatAppGenerateTaskPipeline(GraphRuntimeStateSupport):
|
||||
"""
|
||||
extras = self._task_state.metadata.model_dump()
|
||||
|
||||
if self._task_state.metadata.annotation_reply:
|
||||
del extras["annotation_reply"]
|
||||
|
||||
return MessageEndStreamResponse(
|
||||
task_id=self._application_generate_entity.task_id,
|
||||
id=self._message_id,
|
||||
|
||||
@ -101,10 +101,6 @@ class AppGenerateResponseConverter[TBlockingResponse: AppBlockingResponse](ABC):
|
||||
)
|
||||
metadata["retriever_resources"] = updated_resources
|
||||
|
||||
# show annotation reply
|
||||
if "annotation_reply" in metadata:
|
||||
del metadata["annotation_reply"]
|
||||
|
||||
# show usage
|
||||
if "usage" in metadata:
|
||||
del metadata["usage"]
|
||||
|
||||
@ -316,7 +316,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
assert message.workflow_run_id == "run-id"
|
||||
assert other_message.workflow_run_id is None
|
||||
|
||||
def test_message_end_to_stream_response_strips_annotation_reply(self):
|
||||
def test_message_end_to_stream_response_preserves_annotation_reply(self):
|
||||
pipeline = _make_pipeline()
|
||||
pipeline._task_state.metadata.annotation_reply = AnnotationReply(
|
||||
id="ann",
|
||||
@ -325,7 +325,10 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
|
||||
response = pipeline._message_end_to_stream_response()
|
||||
|
||||
assert "annotation_reply" not in response.metadata
|
||||
assert response.metadata["annotation_reply"] == {
|
||||
"id": "ann",
|
||||
"account": {"id": "acc", "name": "acc"},
|
||||
}
|
||||
|
||||
def test_handle_output_moderation_chunk_publishes_stop(self):
|
||||
pipeline = _make_pipeline()
|
||||
|
||||
@ -71,7 +71,7 @@ class TestAgentChatAppGenerateResponseConverterBlocking:
|
||||
|
||||
result = AgentChatAppGenerateResponseConverter.convert_blocking_simple_response(blocking)
|
||||
|
||||
assert "annotation_reply" not in result["metadata"]
|
||||
assert result["metadata"]["annotation_reply"] == {"id": "a"}
|
||||
assert "usage" not in result["metadata"]
|
||||
|
||||
def test_convert_blocking_simple_response_with_non_dict_metadata(self):
|
||||
@ -169,7 +169,7 @@ class TestAgentChatAppGenerateResponseConverterStream:
|
||||
assert items[2]["event"] == "message_end"
|
||||
assert "metadata" in items[2]
|
||||
metadata = items[2]["metadata"]
|
||||
assert "annotation_reply" not in metadata
|
||||
assert metadata["annotation_reply"] == {"id": "a"}
|
||||
assert "usage" not in metadata
|
||||
assert metadata["retriever_resources"] == [
|
||||
{
|
||||
|
||||
@ -75,7 +75,7 @@ class TestCompletionAppGenerateResponseConverter:
|
||||
|
||||
result = CompletionAppGenerateResponseConverter.convert_blocking_simple_response(blocking)
|
||||
|
||||
assert "annotation_reply" not in result["metadata"]
|
||||
assert result["metadata"]["annotation_reply"] == {"a": 1}
|
||||
assert "usage" not in result["metadata"]
|
||||
assert result["metadata"]["retriever_resources"][0]["dataset_id"] == "dataset-1"
|
||||
assert result["metadata"]["retriever_resources"][0]["document_id"] == "document-1"
|
||||
@ -164,6 +164,6 @@ class TestCompletionAppGenerateResponseConverter:
|
||||
|
||||
assert result[0] == "ping"
|
||||
assert result[1]["event"] == "message_end"
|
||||
assert "annotation_reply" not in result[1]["metadata"]
|
||||
assert result[1]["metadata"]["annotation_reply"] == {"a": 1}
|
||||
assert "usage" not in result[1]["metadata"]
|
||||
assert result[2]["event"] == "error"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user