Remove person_app, open_source app, llama2_app with their configs (#829)
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
from embedchain import App, CustomApp, Llama2App, OpenSourceApp
|
||||
from embedchain import App
|
||||
from embedchain.config import (AddConfig, AppConfig, BaseEmbedderConfig,
|
||||
BaseLlmConfig, ChromaDbConfig)
|
||||
from embedchain.embedder.base import BaseEmbedder
|
||||
@@ -18,49 +18,12 @@ def app():
|
||||
return App()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def custom_app():
|
||||
os.environ["OPENAI_API_KEY"] = "test_api_key"
|
||||
return CustomApp()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def opensource_app():
|
||||
os.environ["OPENAI_API_KEY"] = "test_api_key"
|
||||
return OpenSourceApp()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def llama2_app():
|
||||
os.environ["OPENAI_API_KEY"] = "test_api_key"
|
||||
os.environ["REPLICATE_API_TOKEN"] = "-"
|
||||
return Llama2App()
|
||||
|
||||
|
||||
def test_app(app):
|
||||
assert isinstance(app.llm, BaseLlm)
|
||||
assert isinstance(app.db, BaseVectorDB)
|
||||
assert isinstance(app.embedder, BaseEmbedder)
|
||||
|
||||
|
||||
def test_custom_app(custom_app):
|
||||
assert isinstance(custom_app.llm, BaseLlm)
|
||||
assert isinstance(custom_app.db, BaseVectorDB)
|
||||
assert isinstance(custom_app.embedder, BaseEmbedder)
|
||||
|
||||
|
||||
def test_opensource_app(opensource_app):
|
||||
assert isinstance(opensource_app.llm, BaseLlm)
|
||||
assert isinstance(opensource_app.db, BaseVectorDB)
|
||||
assert isinstance(opensource_app.embedder, BaseEmbedder)
|
||||
|
||||
|
||||
def test_llama2_app(llama2_app):
|
||||
assert isinstance(llama2_app.llm, BaseLlm)
|
||||
assert isinstance(llama2_app.db, BaseVectorDB)
|
||||
assert isinstance(llama2_app.embedder, BaseEmbedder)
|
||||
|
||||
|
||||
class TestConfigForAppComponents:
|
||||
def test_constructor_config(self):
|
||||
collection_name = "my-test-collection"
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from embedchain.apps.app import App
|
||||
from embedchain.apps.person_app import PersonApp, PersonOpenSourceApp
|
||||
from embedchain.config import AppConfig, BaseLlmConfig
|
||||
from embedchain.config.llm.base import DEFAULT_PROMPT
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def person_app():
|
||||
config = AppConfig()
|
||||
return PersonApp("John Doe", config)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def opensource_person_app():
|
||||
config = AppConfig()
|
||||
return PersonOpenSourceApp("John Doe", config)
|
||||
|
||||
|
||||
def test_person_app_initialization(person_app):
|
||||
assert person_app.person == "John Doe"
|
||||
assert f"You are {person_app.person}" in person_app.person_prompt
|
||||
assert isinstance(person_app.config, AppConfig)
|
||||
|
||||
|
||||
def test_person_app_add_person_template_to_config_with_invalid_template():
|
||||
app = PersonApp("John Doe")
|
||||
default_prompt = "Input Prompt"
|
||||
with pytest.raises(ValueError):
|
||||
# as prompt doesn't contain $context and $query
|
||||
app.add_person_template_to_config(default_prompt)
|
||||
|
||||
|
||||
def test_person_app_add_person_template_to_config_with_valid_template():
|
||||
app = PersonApp("John Doe")
|
||||
config = app.add_person_template_to_config(DEFAULT_PROMPT)
|
||||
assert (
|
||||
config.template.template
|
||||
== f"You are John Doe. Whatever you say, you will always say in John Doe style. {DEFAULT_PROMPT}"
|
||||
)
|
||||
|
||||
|
||||
def test_person_app_query(mocker, person_app):
|
||||
input_query = "Hello, how are you?"
|
||||
config = BaseLlmConfig()
|
||||
|
||||
mocker.patch.object(App, "query", return_value="Mocked response")
|
||||
|
||||
result = person_app.query(input_query, config)
|
||||
assert result == "Mocked response"
|
||||
|
||||
|
||||
def test_person_app_chat(mocker, person_app):
|
||||
input_query = "Hello, how are you?"
|
||||
config = BaseLlmConfig()
|
||||
|
||||
mocker.patch.object(App, "chat", return_value="Mocked chat response")
|
||||
|
||||
result = person_app.chat(input_query, config)
|
||||
assert result == "Mocked chat response"
|
||||
|
||||
|
||||
def test_opensource_person_app_query(mocker, opensource_person_app):
|
||||
input_query = "Hello, how are you?"
|
||||
config = BaseLlmConfig()
|
||||
|
||||
mocker.patch.object(App, "query", return_value="Mocked response")
|
||||
|
||||
result = opensource_person_app.query(input_query, config)
|
||||
assert result == "Mocked response"
|
||||
|
||||
|
||||
def test_opensource_person_app_chat(mocker, opensource_person_app):
|
||||
input_query = "Hello, how are you?"
|
||||
config = BaseLlmConfig()
|
||||
|
||||
mocker.patch.object(App, "chat", return_value="Mocked chat response")
|
||||
|
||||
result = opensource_person_app.chat(input_query, config)
|
||||
assert result == "Mocked chat response"
|
||||
@@ -63,7 +63,6 @@ class TestJsonSerializable(unittest.TestCase):
|
||||
config = AppConfig(id=random_id, collect_metrics=False)
|
||||
# config class is set under app.config.
|
||||
app = App(config=config)
|
||||
# w/o recursion it would just be <embedchain.config.apps.OpenSourceAppConfig.OpenSourceAppConfig object at x>
|
||||
s = app.serialize()
|
||||
new_app: App = App.deserialize(s)
|
||||
# The id of the new app is the same as the first one.
|
||||
|
||||
Reference in New Issue
Block a user