def test_complete_with_kwargs(monkeypatch: MonkeyPatch) -> None:
    """Test generation options passed as kwargs to 'complete' override their default values."""
    llm = Llamafile(base_url=BASE_URL)

    def mock_post(self, url, headers, json):  # type: ignore[no-untyped-def]
        assert url == f"{BASE_URL}/completion"
        assert headers == {
            "Content-Type": "application/json",
        }
        generation_opts = dict(DEFAULT_GENERATION_OPTS)
        generation_opts["seed"] = 1
        assert json == {"prompt": "Test prompt", "stream": False, **generation_opts}
        return mock_completion_response()

    monkeypatch.setattr(httpx.Client, "post", mock_post)
    out = llm.complete("Test prompt", seed=1)
    assert str(out) == "the quick brown fox"
Test generation options passed as kwargs to 'complete' override their default values.
llama-index-integrations/llms/llama-index-llms-llamafile/tests/test_llms_llamafile.py