mirror of
https://github.com/langgenius/dify.git
synced 2026-05-26 03:47:42 +08:00
[autofix.ci] apply automated fixes
This commit is contained in:
@ -31,9 +31,7 @@ class PydanticAIHistoryRuntimeState(BaseModel):
|
||||
model_config: ClassVar[ConfigDict] = ConfigDict(extra="forbid", validate_assignment=True)
|
||||
|
||||
|
||||
class PydanticAIHistoryLayer(
|
||||
PydanticAILayer[NoLayerDeps, object, EmptyLayerConfig, PydanticAIHistoryRuntimeState]
|
||||
):
|
||||
class PydanticAIHistoryLayer(PydanticAILayer[NoLayerDeps, object, EmptyLayerConfig, PydanticAIHistoryRuntimeState]):
|
||||
"""State-only layer that stores pydantic-ai message history.
|
||||
|
||||
The mutable history lives only in ``runtime_state.messages``. Helper methods
|
||||
|
||||
@ -47,4 +47,5 @@ class DifyOutputLayerConfig(LayerConfig):
|
||||
raise ValueError("Schema must declare an object output.")
|
||||
return value
|
||||
|
||||
|
||||
__all__ = ["DIFY_OUTPUT_LAYER_TYPE_ID", "DifyOutputLayerConfig"]
|
||||
|
||||
@ -187,6 +187,8 @@ def _build_exposed_json_schema(
|
||||
if description is not None:
|
||||
exposed_schema["description"] = description
|
||||
return exposed_schema
|
||||
|
||||
|
||||
def _reject_non_local_refs(schema: JsonValue) -> None:
|
||||
"""Reject references that would require external fetching or non-local state.
|
||||
|
||||
|
||||
@ -5,7 +5,15 @@ from typing import Any
|
||||
import httpx
|
||||
import pytest
|
||||
from pydantic_ai.exceptions import UnexpectedModelBehavior
|
||||
from pydantic_ai.messages import ModelMessage, ModelRequest, ModelResponse, SystemPromptPart, TextPart, ToolCallPart, UserPromptPart
|
||||
from pydantic_ai.messages import (
|
||||
ModelMessage,
|
||||
ModelRequest,
|
||||
ModelResponse,
|
||||
SystemPromptPart,
|
||||
TextPart,
|
||||
ToolCallPart,
|
||||
UserPromptPart,
|
||||
)
|
||||
from pydantic_ai.models import ModelRequestParameters
|
||||
from pydantic_ai.models.test import TestModel
|
||||
from pydantic_ai.settings import ModelSettings
|
||||
@ -163,11 +171,15 @@ def _history_session_snapshot(
|
||||
runtime_state=PydanticAIHistoryRuntimeState(messages=messages).model_dump(mode="json"),
|
||||
),
|
||||
LayerSessionSnapshot(name="plugin", lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}),
|
||||
LayerSessionSnapshot(name=DIFY_AGENT_MODEL_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}),
|
||||
LayerSessionSnapshot(
|
||||
name=DIFY_AGENT_MODEL_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}
|
||||
),
|
||||
]
|
||||
if include_output:
|
||||
layers.append(
|
||||
LayerSessionSnapshot(name=DIFY_AGENT_OUTPUT_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={})
|
||||
LayerSessionSnapshot(
|
||||
name=DIFY_AGENT_OUTPUT_LAYER_ID, lifecycle_state=LifecycleState.SUSPENDED, runtime_state={}
|
||||
)
|
||||
)
|
||||
return CompositorSessionSnapshot(layers=layers)
|
||||
|
||||
@ -257,7 +269,11 @@ def test_runner_passes_temporary_system_prompt_prefix_without_history_layer(monk
|
||||
assert request_parts[1].content == "current user"
|
||||
terminal = sink.events["run-no-history"][-1]
|
||||
assert isinstance(terminal, RunSucceededEvent)
|
||||
assert [layer.name for layer in terminal.data.session_snapshot.layers] == ["prompt", "plugin", DIFY_AGENT_MODEL_LAYER_ID]
|
||||
assert [layer.name for layer in terminal.data.session_snapshot.layers] == [
|
||||
"prompt",
|
||||
"plugin",
|
||||
DIFY_AGENT_MODEL_LAYER_ID,
|
||||
]
|
||||
|
||||
|
||||
def test_runner_prepends_current_system_prompt_to_stored_history_and_appends_only_new_messages(
|
||||
|
||||
Reference in New Issue
Block a user