* activate directory to gitignore * add my custom env to gitignore, will have to change that * add unstructured to kotaemon pyproject.toml * add .env to gitignore * remove .env from tracking * make changes to the run_macos script, update readme with more detailed instructions * remove my personal changes from gitignore * remove line from run_macos script * remove option for not installing miniconda for non technical users, mark docker dependency as optional * docs: update demo URL * gitignore changes * merge .env.example * revert changes to run_macos.sh * unstructured to advanced dependencies * add link to unstructured system dependencies * remove api key * fix: skip tests when unstructured pdf not installed * chore: loosen unstructured package version in pyproject.toml * chore: correct syntax --------- Co-authored-by: Tadashi <tadashi@cinnamon.is> Co-authored-by: cin-albert <albert@cinnamon.is>
100 lines
2.3 KiB
Python
100 lines
2.3 KiB
Python
import pytest
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def mock_google_search(monkeypatch):
|
|
import googlesearch
|
|
|
|
def result(*args, **kwargs):
|
|
yield googlesearch.SearchResult(
|
|
url="https://www.cinnamon.is/en/",
|
|
title="Cinnamon AI",
|
|
description="Cinnamon AI is an enterprise AI company.",
|
|
)
|
|
|
|
monkeypatch.setattr(googlesearch, "search", result)
|
|
|
|
|
|
def if_haystack_not_installed():
|
|
try:
|
|
import haystack # noqa: F401
|
|
except ImportError:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def if_sentence_bert_not_installed():
|
|
try:
|
|
import sentence_transformers # noqa: F401
|
|
except ImportError:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def if_sentence_fastembed_not_installed():
|
|
try:
|
|
import fastembed # noqa: F401
|
|
except ImportError:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def if_unstructured_pdf_not_installed():
|
|
try:
|
|
import unstructured # noqa: F401
|
|
from unstructured.partition.pdf import partition_pdf # noqa: F401
|
|
except ImportError:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def if_cohere_not_installed():
|
|
try:
|
|
import cohere # noqa: F401
|
|
except ImportError:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def if_llama_cpp_not_installed():
|
|
try:
|
|
import llama_cpp # noqa: F401
|
|
except ImportError:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
skip_when_haystack_not_installed = pytest.mark.skipif(
|
|
if_haystack_not_installed(), reason="Haystack is not installed"
|
|
)
|
|
|
|
skip_when_sentence_bert_not_installed = pytest.mark.skipif(
|
|
if_sentence_bert_not_installed(), reason="SBert is not installed"
|
|
)
|
|
|
|
skip_when_fastembed_not_installed = pytest.mark.skipif(
|
|
if_sentence_fastembed_not_installed(), reason="fastembed is not installed"
|
|
)
|
|
|
|
skip_when_unstructured_pdf_not_installed = pytest.mark.skipif(
|
|
if_unstructured_pdf_not_installed(), reason="unstructured is not installed"
|
|
)
|
|
|
|
skip_when_cohere_not_installed = pytest.mark.skipif(
|
|
if_cohere_not_installed(), reason="cohere is not installed"
|
|
)
|
|
|
|
skip_openai_lc_wrapper_test = pytest.mark.skipif(
|
|
True, reason="OpenAI LC wrapper test is skipped"
|
|
)
|
|
|
|
skip_llama_cpp_not_installed = pytest.mark.skipif(
|
|
if_llama_cpp_not_installed(), reason="llama_cpp is not installed"
|
|
)
|