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 | from langchain_community.llms.gpt4all import GPT4All as LangchainGPT4All |
| #3 | |
| #4 | from embedchain.config import BaseLlmConfig |
| #5 | from embedchain.llm.gpt4all import GPT4ALLLlm |
| #6 | |
| #7 | |
| #8 | @pytest.fixture |
| #9 | def config(): |
| #10 | config = BaseLlmConfig( |
| #11 | temperature=0.7, |
| #12 | max_tokens=50, |
| #13 | top_p=0.8, |
| #14 | stream=False, |
| #15 | system_prompt="System prompt", |
| #16 | model="orca-mini-3b-gguf2-q4_0.gguf", |
| #17 | ) |
| #18 | yield config |
| #19 | |
| #20 | |
| #21 | @pytest.fixture |
| #22 | def gpt4all_with_config(config): |
| #23 | return GPT4ALLLlm(config=config) |
| #24 | |
| #25 | |
| #26 | @pytest.fixture |
| #27 | def gpt4all_without_config(): |
| #28 | return GPT4ALLLlm() |
| #29 | |
| #30 | |
| #31 | def test_gpt4all_init_with_config(config, gpt4all_with_config): |
| #32 | assert gpt4all_with_config.config.temperature == config.temperature |
| #33 | assert gpt4all_with_config.config.max_tokens == config.max_tokens |
| #34 | assert gpt4all_with_config.config.top_p == config.top_p |
| #35 | assert gpt4all_with_config.config.stream == config.stream |
| #36 | assert gpt4all_with_config.config.system_prompt == config.system_prompt |
| #37 | assert gpt4all_with_config.config.model == config.model |
| #38 | |
| #39 | assert isinstance(gpt4all_with_config.instance, LangchainGPT4All) |
| #40 | |
| #41 | |
| #42 | def test_gpt4all_init_without_config(gpt4all_without_config): |
| #43 | assert gpt4all_without_config.config.model == "orca-mini-3b-gguf2-q4_0.gguf" |
| #44 | assert isinstance(gpt4all_without_config.instance, LangchainGPT4All) |
| #45 | |
| #46 | |
| #47 | def test_get_llm_model_answer(mocker, gpt4all_with_config): |
| #48 | test_query = "Test query" |
| #49 | test_answer = "Test answer" |
| #50 | |
| #51 | mocked_get_answer = mocker.patch("embedchain.llm.gpt4all.GPT4ALLLlm._get_answer", return_value=test_answer) |
| #52 | answer = gpt4all_with_config.get_llm_model_answer(test_query) |
| #53 | |
| #54 | assert answer == test_answer |
| #55 | mocked_get_answer.assert_called_once_with(prompt=test_query, config=gpt4all_with_config.config) |
| #56 | |
| #57 | |
| #58 | def test_gpt4all_model_switching(gpt4all_with_config): |
| #59 | with pytest.raises(RuntimeError, match="GPT4ALLLlm does not support switching models at runtime."): |
| #60 | gpt4all_with_config._get_answer("Test prompt", BaseLlmConfig(model="new_model")) |
| #61 |