Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cwang committed Jun 16, 2023
1 parent 4d57278 commit 6205015
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/docq/support/llm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from langchain.schema import BaseMessage
from llama_index.query_engine.graph_query_engine import ComposableGraphQueryEngine
from llama_index.indices.composability import ComposableGraph
from llama_index.chat_engine import SimpleChatEngine


# def test_run_ask_with_personal_space_only():
Expand Down Expand Up @@ -60,12 +61,18 @@


def test_run_chat():
with patch("docq.support.llm._get_chat_model") as mock_get_chat_model:
mock_chat_openai = Mock(ChatOpenAI)
mock_get_chat_model.return_value = mock_chat_openai
mock_chat_openai.return_value = "LLM response"
with patch.object(SimpleChatEngine, "from_defaults") as mock_simple_chat_engine, patch(
"docq.support.llm._get_service_context"
) as mock_get_service_context:
mock_get_service_context.return_value = Mock(ServiceContext)
mocked_engine = Mock(SimpleChatEngine)
mock_simple_chat_engine.return_value = mocked_engine
mocked_chat = Mock()
mocked_engine.chat = mocked_chat
mocked_chat.return_value = "LLM response"

response = run_chat("My ask", "My chat history")
mocked_chat.assert_called_once_with("My ask")
assert response == "LLM response"


Expand Down

0 comments on commit 6205015

Please sign in to comment.