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 | import yaml |
| #5 | |
| #6 | from embedchain import App |
| #7 | from embedchain.config import ChromaDbConfig |
| #8 | from embedchain.embedder.base import BaseEmbedder |
| #9 | from embedchain.llm.base import BaseLlm |
| #10 | from embedchain.vectordb.base import BaseVectorDB |
| #11 | from embedchain.vectordb.chroma import ChromaDB |
| #12 | |
| #13 | |
| #14 | @pytest.fixture |
| #15 | def app(): |
| #16 | os.environ["OPENAI_API_KEY"] = "test-api-key" |
| #17 | os.environ["OPENAI_API_BASE"] = "test-api-base" |
| #18 | return App() |
| #19 | |
| #20 | |
| #21 | def test_app(app): |
| #22 | assert isinstance(app.llm, BaseLlm) |
| #23 | assert isinstance(app.db, BaseVectorDB) |
| #24 | assert isinstance(app.embedding_model, BaseEmbedder) |
| #25 | |
| #26 | |
| #27 | class TestConfigForAppComponents: |
| #28 | def test_constructor_config(self): |
| #29 | collection_name = "my-test-collection" |
| #30 | db = ChromaDB(config=ChromaDbConfig(collection_name=collection_name)) |
| #31 | app = App(db=db) |
| #32 | assert app.db.config.collection_name == collection_name |
| #33 | |
| #34 | def test_component_config(self): |
| #35 | collection_name = "my-test-collection" |
| #36 | database = ChromaDB(config=ChromaDbConfig(collection_name=collection_name)) |
| #37 | app = App(db=database) |
| #38 | assert app.db.config.collection_name == collection_name |
| #39 | |
| #40 | |
| #41 | class TestAppFromConfig: |
| #42 | def load_config_data(self, yaml_path): |
| #43 | with open(yaml_path, "r") as file: |
| #44 | return yaml.safe_load(file) |
| #45 | |
| #46 | def test_from_chroma_config(self, mocker): |
| #47 | mocker.patch("embedchain.vectordb.chroma.chromadb.Client") |
| #48 | |
| #49 | yaml_path = "configs/chroma.yaml" |
| #50 | config_data = self.load_config_data(yaml_path) |
| #51 | |
| #52 | app = App.from_config(config_path=yaml_path) |
| #53 | |
| #54 | # Check if the App instance and its components were created correctly |
| #55 | assert isinstance(app, App) |
| #56 | |
| #57 | # Validate the AppConfig values |
| #58 | assert app.config.id == config_data["app"]["config"]["id"] |
| #59 | # Even though not present in the config, the default value is used |
| #60 | assert app.config.collect_metrics is True |
| #61 | |
| #62 | # Validate the LLM config values |
| #63 | llm_config = config_data["llm"]["config"] |
| #64 | assert app.llm.config.temperature == llm_config["temperature"] |
| #65 | assert app.llm.config.max_tokens == llm_config["max_tokens"] |
| #66 | assert app.llm.config.top_p == llm_config["top_p"] |
| #67 | assert app.llm.config.stream == llm_config["stream"] |
| #68 | |
| #69 | # Validate the VectorDB config values |
| #70 | db_config = config_data["vectordb"]["config"] |
| #71 | assert app.db.config.collection_name == db_config["collection_name"] |
| #72 | assert app.db.config.dir == db_config["dir"] |
| #73 | assert app.db.config.allow_reset == db_config["allow_reset"] |
| #74 | |
| #75 | # Validate the Embedder config values |
| #76 | embedder_config = config_data["embedder"]["config"] |
| #77 | assert app.embedding_model.config.model == embedder_config["model"] |
| #78 | assert app.embedding_model.config.deployment_name == embedder_config.get("deployment_name") |
| #79 | |
| #80 | def test_from_opensource_config(self, mocker): |
| #81 | mocker.patch("embedchain.vectordb.chroma.chromadb.Client") |
| #82 | |
| #83 | yaml_path = "configs/opensource.yaml" |
| #84 | config_data = self.load_config_data(yaml_path) |
| #85 | |
| #86 | app = App.from_config(yaml_path) |
| #87 | |
| #88 | # Check if the App instance and its components were created correctly |
| #89 | assert isinstance(app, App) |
| #90 | |
| #91 | # Validate the AppConfig values |
| #92 | assert app.config.id == config_data["app"]["config"]["id"] |
| #93 | assert app.config.collect_metrics == config_data["app"]["config"]["collect_metrics"] |
| #94 | |
| #95 | # Validate the LLM config values |
| #96 | llm_config = config_data["llm"]["config"] |
| #97 | assert app.llm.config.model == llm_config["model"] |
| #98 | assert app.llm.config.temperature == llm_config["temperature"] |
| #99 | assert app.llm.config.max_tokens == llm_config["max_tokens"] |
| #100 | assert app.llm.config.top_p == llm_config["top_p"] |
| #101 | assert app.llm.config.stream == llm_config["stream"] |
| #102 | |
| #103 | # Validate the VectorDB config values |
| #104 | db_config = config_data["vectordb"]["config"] |
| #105 | assert app.db.config.collection_name == db_config["collection_name"] |
| #106 | assert app.db.config.dir == db_config["dir"] |
| #107 | assert app.db.config.allow_reset == db_config["allow_reset"] |
| #108 | |
| #109 | # Validate the Embedder config values |
| #110 | embedder_config = config_data["embedder"]["config"] |
| #111 | assert app.embedding_model.config.deployment_name == embedder_config["deployment_name"] |
| #112 |