repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import pytest |
| #2 | |
| #3 | from embedchain.config import BaseLlmConfig |
| #4 | from embedchain.llm.google import GoogleLlm |
| #5 | |
| #6 | |
| #7 | @pytest.fixture |
| #8 | def google_llm_config(): |
| #9 | return BaseLlmConfig(model="gemini-pro", max_tokens=100, temperature=0.7, top_p=0.5, stream=False) |
| #10 | |
| #11 | |
| #12 | def test_google_llm_init_missing_api_key(monkeypatch): |
| #13 | monkeypatch.delenv("GOOGLE_API_KEY", raising=False) |
| #14 | with pytest.raises(ValueError, match="Please set the GOOGLE_API_KEY environment variable."): |
| #15 | GoogleLlm() |
| #16 | |
| #17 | |
| #18 | def test_google_llm_init(monkeypatch): |
| #19 | monkeypatch.setenv("GOOGLE_API_KEY", "fake_api_key") |
| #20 | with monkeypatch.context() as m: |
| #21 | m.setattr("importlib.import_module", lambda x: None) |
| #22 | google_llm = GoogleLlm() |
| #23 | assert google_llm is not None |
| #24 | |
| #25 | |
| #26 | def test_google_llm_get_llm_model_answer_with_system_prompt(monkeypatch): |
| #27 | monkeypatch.setenv("GOOGLE_API_KEY", "fake_api_key") |
| #28 | monkeypatch.setattr("importlib.import_module", lambda x: None) |
| #29 | google_llm = GoogleLlm(config=BaseLlmConfig(system_prompt="system prompt")) |
| #30 | with pytest.raises(ValueError, match="GoogleLlm does not support `system_prompt`"): |
| #31 | google_llm.get_llm_model_answer("test prompt") |
| #32 | |
| #33 | |
| #34 | def test_google_llm_get_llm_model_answer(monkeypatch, google_llm_config): |
| #35 | def mock_get_answer(prompt, config): |
| #36 | return "Generated Text" |
| #37 | |
| #38 | monkeypatch.setenv("GOOGLE_API_KEY", "fake_api_key") |
| #39 | monkeypatch.setattr(GoogleLlm, "_get_answer", mock_get_answer) |
| #40 | google_llm = GoogleLlm(config=google_llm_config) |
| #41 | result = google_llm.get_llm_model_answer("test prompt") |
| #42 | |
| #43 | assert result == "Generated Text" |
| #44 |