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 os |
| #2 | |
| #3 | import pytest |
| #4 | |
| #5 | import embedchain |
| #6 | import embedchain.embedder.gpt4all |
| #7 | import embedchain.embedder.huggingface |
| #8 | import embedchain.embedder.openai |
| #9 | import embedchain.embedder.vertexai |
| #10 | import embedchain.llm.anthropic |
| #11 | import embedchain.llm.openai |
| #12 | import embedchain.vectordb.chroma |
| #13 | import embedchain.vectordb.elasticsearch |
| #14 | import embedchain.vectordb.opensearch |
| #15 | from embedchain.factory import EmbedderFactory, LlmFactory, VectorDBFactory |
| #16 | |
| #17 | |
| #18 | class TestFactories: |
| #19 | @pytest.mark.parametrize( |
| #20 | "provider_name, config_data, expected_class", |
| #21 | [ |
| #22 | ("openai", {}, embedchain.llm.openai.OpenAILlm), |
| #23 | ("anthropic", {}, embedchain.llm.anthropic.AnthropicLlm), |
| #24 | ], |
| #25 | ) |
| #26 | def test_llm_factory_create(self, provider_name, config_data, expected_class): |
| #27 | os.environ["ANTHROPIC_API_KEY"] = "test_api_key" |
| #28 | os.environ["OPENAI_API_KEY"] = "test_api_key" |
| #29 | os.environ["OPENAI_API_BASE"] = "test_api_base" |
| #30 | llm_instance = LlmFactory.create(provider_name, config_data) |
| #31 | assert isinstance(llm_instance, expected_class) |
| #32 | |
| #33 | @pytest.mark.parametrize( |
| #34 | "provider_name, config_data, expected_class", |
| #35 | [ |
| #36 | ("gpt4all", {}, embedchain.embedder.gpt4all.GPT4AllEmbedder), |
| #37 | ( |
| #38 | "huggingface", |
| #39 | {"model": "sentence-transformers/all-mpnet-base-v2", "vector_dimension": 768}, |
| #40 | embedchain.embedder.huggingface.HuggingFaceEmbedder, |
| #41 | ), |
| #42 | ("vertexai", {"model": "textembedding-gecko"}, embedchain.embedder.vertexai.VertexAIEmbedder), |
| #43 | ("openai", {}, embedchain.embedder.openai.OpenAIEmbedder), |
| #44 | ], |
| #45 | ) |
| #46 | def test_embedder_factory_create(self, mocker, provider_name, config_data, expected_class): |
| #47 | mocker.patch("embedchain.embedder.vertexai.VertexAIEmbedder", autospec=True) |
| #48 | embedder_instance = EmbedderFactory.create(provider_name, config_data) |
| #49 | assert isinstance(embedder_instance, expected_class) |
| #50 | |
| #51 | @pytest.mark.parametrize( |
| #52 | "provider_name, config_data, expected_class", |
| #53 | [ |
| #54 | ("chroma", {}, embedchain.vectordb.chroma.ChromaDB), |
| #55 | ( |
| #56 | "opensearch", |
| #57 | {"opensearch_url": "http://localhost:9200", "http_auth": ("admin", "admin")}, |
| #58 | embedchain.vectordb.opensearch.OpenSearchDB, |
| #59 | ), |
| #60 | ("elasticsearch", {"es_url": "http://localhost:9200"}, embedchain.vectordb.elasticsearch.ElasticsearchDB), |
| #61 | ], |
| #62 | ) |
| #63 | def test_vectordb_factory_create(self, mocker, provider_name, config_data, expected_class): |
| #64 | mocker.patch("embedchain.vectordb.opensearch.OpenSearchDB", autospec=True) |
| #65 | vectordb_instance = VectorDBFactory.create(provider_name, config_data) |
| #66 | assert isinstance(vectordb_instance, expected_class) |
| #67 |