diff --git a/python/flink_agents/e2e_tests/e2e_tests_integration/chat_model_integration_test.py b/python/flink_agents/e2e_tests/e2e_tests_integration/chat_model_integration_test.py index 07bae38e9..ddebe7d80 100644 --- a/python/flink_agents/e2e_tests/e2e_tests_integration/chat_model_integration_test.py +++ b/python/flink_agents/e2e_tests/e2e_tests_integration/chat_model_integration_test.py @@ -29,17 +29,12 @@ current_dir = Path(__file__).parent TONGYI_MODEL = os.environ.get("TONGYI_CHAT_MODEL", "qwen-plus") -os.environ["TONGYI_CHAT_MODEL"] = TONGYI_MODEL OLLAMA_MODEL = os.environ.get("OLLAMA_CHAT_MODEL", "qwen3:1.7b") -os.environ["OLLAMA_CHAT_MODEL"] = OLLAMA_MODEL OPENAI_MODEL = os.environ.get("OPENAI_CHAT_MODEL", "gpt-3.5-turbo") -os.environ["OPENAI_CHAT_MODEL"] = OPENAI_MODEL AZURE_OPENAI_MODEL = os.environ.get("AZURE_OPENAI_CHAT_MODEL", "gpt-5") -os.environ["AZURE_OPENAI_CHAT_MODEL"] = AZURE_OPENAI_MODEL AZURE_OPENAI_API_VERSION = os.environ.get( "AZURE_OPENAI_API_VERSION", "2025-04-01-preview" ) -os.environ["AZURE_OPENAI_API_VERSION"] = AZURE_OPENAI_API_VERSION DASHSCOPE_API_KEY = os.environ.get("DASHSCOPE_API_KEY") OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY") @@ -78,8 +73,15 @@ ), ], ) -def test_chat_model_integration(model_provider: str) -> None: - os.environ["MODEL_PROVIDER"] = model_provider +def test_chat_model_integration( + model_provider: str, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("TONGYI_CHAT_MODEL", TONGYI_MODEL) + monkeypatch.setenv("OLLAMA_CHAT_MODEL", OLLAMA_MODEL) + monkeypatch.setenv("OPENAI_CHAT_MODEL", OPENAI_MODEL) + monkeypatch.setenv("AZURE_OPENAI_CHAT_MODEL", AZURE_OPENAI_MODEL) + monkeypatch.setenv("AZURE_OPENAI_API_VERSION", AZURE_OPENAI_API_VERSION) + monkeypatch.setenv("MODEL_PROVIDER", model_provider) env = AgentsExecutionEnvironment.get_execution_environment() input_list = [] agent = ChatModelTestAgent() diff --git a/python/flink_agents/e2e_tests/e2e_tests_integration/react_agent_test.py b/python/flink_agents/e2e_tests/e2e_tests_integration/react_agent_test.py index 85cd42bfd..04d0be41d 100644 --- a/python/flink_agents/e2e_tests/e2e_tests_integration/react_agent_test.py +++ b/python/flink_agents/e2e_tests/e2e_tests_integration/react_agent_test.py @@ -51,7 +51,6 @@ os.environ["PYTHONPATH"] = sysconfig.get_paths()["purelib"] OLLAMA_MODEL = os.environ.get("REACT_OLLAMA_MODEL", "qwen3:1.7b") -os.environ["OLLAMA_CHAT_MODEL"] = OLLAMA_MODEL class InputData(BaseModel): @@ -78,7 +77,8 @@ def get_key(self, value: Row) -> int: @pytest.mark.skipif( client is None, reason="Ollama client is not available or test model is missing" ) -def test_react_agent_on_local_runner() -> None: +def test_react_agent_on_local_runner(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("OLLAMA_CHAT_MODEL", OLLAMA_MODEL) env = AgentsExecutionEnvironment.get_execution_environment() env.get_config().set( AgentExecutionOptions.ERROR_HANDLING_STRATEGY, ErrorHandlingStrategy.RETRY @@ -138,7 +138,10 @@ def test_react_agent_on_local_runner() -> None: @pytest.mark.skipif( client is None, reason="Ollama client is not available or test model is missing" ) -def test_react_agent_on_remote_runner(tmp_path: Path) -> None: +def test_react_agent_on_remote_runner( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("OLLAMA_CHAT_MODEL", OLLAMA_MODEL) stream_env = StreamExecutionEnvironment.get_execution_environment() stream_env.set_parallelism(1) diff --git a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/chat_model_cross_language_test.py b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/chat_model_cross_language_test.py index 42a5dd719..c17110954 100644 --- a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/chat_model_cross_language_test.py +++ b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/chat_model_cross_language_test.py @@ -41,7 +41,6 @@ current_dir = Path(__file__).parent OLLAMA_MODEL = os.environ.get("OLLAMA_CHAT_MODEL", "qwen3:1.7b") -os.environ["OLLAMA_CHAT_MODEL"] = OLLAMA_MODEL client = pull_model(OLLAMA_MODEL) @@ -51,7 +50,10 @@ @pytest.mark.skipif( client is None, reason="Ollama client is not available or test model is missing." ) -def test_java_chat_model_integration(tmp_path: Path) -> None: +def test_java_chat_model_integration( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setenv("OLLAMA_CHAT_MODEL", OLLAMA_MODEL) env = StreamExecutionEnvironment.get_execution_environment() env.set_runtime_mode(RuntimeExecutionMode.STREAMING) env.set_parallelism(1) diff --git a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/yaml_cross_language_test.py b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/yaml_cross_language_test.py index ae9920f4e..442c729eb 100644 --- a/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/yaml_cross_language_test.py +++ b/python/flink_agents/e2e_tests/e2e_tests_resource_cross_language/yaml_cross_language_test.py @@ -69,7 +69,6 @@ os.environ["PYTHONPATH"] = sysconfig.get_paths()["purelib"] OLLAMA_MODEL = os.environ.get("OLLAMA_CHAT_MODEL", "qwen3:1.7b") -os.environ["OLLAMA_CHAT_MODEL"] = OLLAMA_MODEL _client = pull_model(OLLAMA_MODEL) @@ -86,13 +85,16 @@ "flink-agents-end-to-end-tests-resource-cross-language' first." ), ) -def test_yaml_cross_language_agent(tmp_path: Path) -> None: +def test_yaml_cross_language_agent( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: """``load_yaml`` → ``apply(by name)`` with a YAML-declared Java tool. Exercises a Python Ollama chat model that calls a Java ``calculateBMI`` tool declared in YAML and resolved against the cross-language test JAR. """ + monkeypatch.setenv("OLLAMA_CHAT_MODEL", OLLAMA_MODEL) config = Configuration() config.set_string("python.pythonpath", sysconfig.get_paths()["purelib"]) env = StreamExecutionEnvironment.get_execution_environment(config)