|
|
|
|
@ -8,8 +8,6 @@ from unittest.mock import MagicMock, patch
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from app_factory import create_app
|
|
|
|
|
from configs import dify_config
|
|
|
|
|
from core.app.entities.app_invoke_entities import InvokeFrom
|
|
|
|
|
from core.model_runtime.entities.llm_entities import LLMResult, LLMUsage
|
|
|
|
|
from core.model_runtime.entities.message_entities import AssistantPromptMessage
|
|
|
|
|
@ -30,21 +28,6 @@ from tests.integration_tests.model_runtime.__mock.plugin_daemon import setup_mod
|
|
|
|
|
from tests.integration_tests.workflow.nodes.__mock.code_executor import setup_code_executor_mock
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
|
def app():
|
|
|
|
|
# Set up storage configuration
|
|
|
|
|
os.environ["STORAGE_TYPE"] = "opendal"
|
|
|
|
|
os.environ["OPENDAL_SCHEME"] = "fs"
|
|
|
|
|
os.environ["OPENDAL_FS_ROOT"] = "storage"
|
|
|
|
|
|
|
|
|
|
# Ensure storage directory exists
|
|
|
|
|
os.makedirs("storage", exist_ok=True)
|
|
|
|
|
|
|
|
|
|
app = create_app()
|
|
|
|
|
dify_config.LOGIN_DISABLED = True
|
|
|
|
|
return app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init_llm_node(config: dict) -> LLMNode:
|
|
|
|
|
graph_config = {
|
|
|
|
|
"edges": [
|
|
|
|
|
@ -102,8 +85,7 @@ def init_llm_node(config: dict) -> LLMNode:
|
|
|
|
|
return node
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_execute_llm(app):
|
|
|
|
|
with app.app_context():
|
|
|
|
|
def test_execute_llm(flask_req_ctx):
|
|
|
|
|
node = init_llm_node(
|
|
|
|
|
config={
|
|
|
|
|
"id": "llm",
|
|
|
|
|
@ -194,11 +176,10 @@ def test_execute_llm(app):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("setup_code_executor_mock", [["none"]], indirect=True)
|
|
|
|
|
def test_execute_llm_with_jinja2(app, setup_code_executor_mock):
|
|
|
|
|
def test_execute_llm_with_jinja2(flask_req_ctx, setup_code_executor_mock):
|
|
|
|
|
"""
|
|
|
|
|
Test execute LLM node with jinja2
|
|
|
|
|
"""
|
|
|
|
|
with app.app_context():
|
|
|
|
|
node = init_llm_node(
|
|
|
|
|
config={
|
|
|
|
|
"id": "llm",
|
|
|
|
|
|