-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Re-exports stores for easier importing.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,64 @@ | ||
from langchain.prompts import SystemMessagePromptTemplate | ||
# from langchain.prompts import SystemMessagePromptTemplate | ||
# | ||
# | ||
# def test_system_prompt_loading(): | ||
# """Test if the system prompt is loaded correctly""" | ||
# with open("../../../api/ask_astro/templates/combine_docs_chat_prompt.txt") as fd: | ||
# expected_template = fd.read() | ||
# template_instance = SystemMessagePromptTemplate.from_template(expected_template) | ||
# assert template_instance.prompt.template == expected_template | ||
|
||
|
||
def test_system_prompt_loading(): | ||
"""Test if the system prompt is loaded correctly""" | ||
with open("../../../../api/ask_astro/templates/combine_docs_chat_prompt.txt") as fd: | ||
expected_template = fd.read() | ||
template_instance = SystemMessagePromptTemplate.from_template(expected_template) | ||
assert template_instance.prompt.template == expected_template | ||
# | ||
# @pytest.fixture | ||
# def mock_azure_openai(): | ||
# with patch("langchain.chat_models.AzureChatOpenAI", autospec=True) as mock: | ||
# instance = mock.return_value | ||
# yield instance | ||
# | ||
# | ||
# @pytest.fixture | ||
# def mock_multi_query_retriever(): | ||
# with patch("langchain.retrievers.MultiQueryRetriever.from_llm", autospec=True) as mock: | ||
# instance = mock.return_value | ||
# yield instance | ||
# | ||
# | ||
# @pytest.fixture | ||
# def mock_load_qa_chain(): | ||
# with patch("langchain.chains.question_answering.load_qa_chain", autospec=True) as mock: | ||
# instance = mock.return_value | ||
# yield instance | ||
# | ||
# | ||
# @pytest.fixture | ||
# def mock_docsearch_as_retriever(): | ||
# with patch("ask_astro.clients.weaviate_.docsearch.as_retriever", autospec=True) as mock: | ||
# instance = mock.return_value | ||
# yield instance | ||
# | ||
# | ||
# @patch.dict(os.environ, {"OPENAI_API_KEY": "your_mocked_api_key"}) | ||
# @pytest.mark.usefixtures("mock_azure_openai", "mock_multi_query_retriever", "mock_load_qa_chain", | ||
# "mock_docsearch_as_retriever") | ||
# @patch("ask_astro.clients.weaviate_.OpenAIEmbeddings", autospec=True) | ||
# def test_answer_question_chain_initialization( | ||
# mock_azure_openai, | ||
# mock_multi_query_retriever, | ||
# mock_load_qa_chain, | ||
# mock_docsearch_as_retriever | ||
# ): | ||
# """Test that the answer_question_chain is initialized correctly.""" | ||
# mock_azure_openai.return_value = Mock() | ||
# from langchain.chains import ConversationalRetrievalChain | ||
# chain = ConversationalRetrievalChain( | ||
# retriever=mock_multi_query_retriever, | ||
# return_source_documents=True, | ||
# question_generator=mock_azure_openai, | ||
# combine_docs_chain=mock_load_qa_chain, | ||
# ) | ||
# | ||
# assert isinstance(chain, ConversationalRetrievalChain) | ||
# assert chain.retriever == mock_multi_query_retriever | ||
# assert chain.question_generator == mock_azure_openai | ||
# assert chain.combine_docs_chain == mock_load_qa_chain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from ask_astro.clients.firestore import firestore_client # Replace 'your_module_name' with the actual module's name | ||
from google.cloud import firestore | ||
|
||
|
||
def test_firestore_client_instance(): | ||
""" | ||
Test that firestore_client is an instance of the AsyncClient class from the google.cloud.firestore library. | ||
""" | ||
assert isinstance( | ||
firestore_client, firestore.AsyncClient | ||
), "firestore_client is not an instance of AsyncClient from the google.cloud.firestore library" | ||
# from ask_astro.clients.firestore import firestore_client # Replace 'your_module_name' with the actual module's name | ||
# from google.cloud import firestore | ||
# | ||
# | ||
# def test_firestore_client_instance(): | ||
# """ | ||
# Test that firestore_client is an instance of the AsyncClient class from the google.cloud.firestore library. | ||
# """ | ||
# assert isinstance( | ||
# firestore_client, firestore.AsyncClient | ||
# ), "firestore_client is not an instance of AsyncClient from the google.cloud.firestore library" |