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 | from string import Template |
| #2 | |
| #3 | import pytest |
| #4 | |
| #5 | from embedchain.llm.base import BaseLlm, BaseLlmConfig |
| #6 | |
| #7 | |
| #8 | @pytest.fixture |
| #9 | def base_llm(): |
| #10 | config = BaseLlmConfig() |
| #11 | return BaseLlm(config=config) |
| #12 | |
| #13 | |
| #14 | def test_is_get_llm_model_answer_not_implemented(base_llm): |
| #15 | with pytest.raises(NotImplementedError): |
| #16 | base_llm.get_llm_model_answer() |
| #17 | |
| #18 | |
| #19 | def test_is_stream_bool(): |
| #20 | with pytest.raises(ValueError): |
| #21 | config = BaseLlmConfig(stream="test value") |
| #22 | BaseLlm(config=config) |
| #23 | |
| #24 | |
| #25 | def test_template_string_gets_converted_to_Template_instance(): |
| #26 | config = BaseLlmConfig(template="test value $query $context") |
| #27 | llm = BaseLlm(config=config) |
| #28 | assert isinstance(llm.config.prompt, Template) |
| #29 | |
| #30 | |
| #31 | def test_is_get_llm_model_answer_implemented(): |
| #32 | class TestLlm(BaseLlm): |
| #33 | def get_llm_model_answer(self): |
| #34 | return "Implemented" |
| #35 | |
| #36 | config = BaseLlmConfig() |
| #37 | llm = TestLlm(config=config) |
| #38 | assert llm.get_llm_model_answer() == "Implemented" |
| #39 | |
| #40 | |
| #41 | def test_stream_response(base_llm): |
| #42 | answer = ["Chunk1", "Chunk2", "Chunk3"] |
| #43 | result = list(base_llm._stream_response(answer)) |
| #44 | assert result == answer |
| #45 | |
| #46 | |
| #47 | def test_append_search_and_context(base_llm): |
| #48 | context = "Context" |
| #49 | web_search_result = "Web Search Result" |
| #50 | result = base_llm._append_search_and_context(context, web_search_result) |
| #51 | expected_result = "Context\nWeb Search Result: Web Search Result" |
| #52 | assert result == expected_result |
| #53 | |
| #54 | |
| #55 | def test_access_search_and_get_results(base_llm, mocker): |
| #56 | base_llm.access_search_and_get_results = mocker.patch.object( |
| #57 | base_llm, "access_search_and_get_results", return_value="Search Results" |
| #58 | ) |
| #59 | input_query = "Test query" |
| #60 | result = base_llm.access_search_and_get_results(input_query) |
| #61 | assert result == "Search Results" |
| #62 |