Skip to content

Commit

Permalink
Tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
williamjameshandley committed Nov 3, 2024
1 parent 3884e56 commit 1d160e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions gptcli/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ def __init__(self, assistant: Assistant, markdown: bool, show_price: bool, strea
listeners.append(PriceChatListener(assistant))

listener = CompositeChatListener(listeners)
self.stream = stream
super().__init__(assistant, listener)
super().__init__(assistant, listener, stream)


def run_interactive(args, assistant):
Expand Down
2 changes: 2 additions & 0 deletions gptcli/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ def __init__(
self,
assistant: Assistant,
listener: ChatListener,
stream: bool = True,
):
self.assistant = assistant
self.messages: List[Message] = assistant.init_messages()
self.user_prompts: List[Tuple[Message, ModelOverrides]] = []
self.listener = listener
self.stream = stream

def _clear(self):
self.messages = self.assistant.init_messages()
Expand Down
16 changes: 8 additions & 8 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_simple_input():
assistant_message = {"role": "assistant", "content": expected_response}

assistant_mock.complete_chat.assert_called_once_with(
[system_message, user_message], override_params={}
[system_message, user_message], override_params={}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls(
[mock.call(user_message), mock.call(assistant_message)]
Expand All @@ -66,7 +66,7 @@ def test_clear():

assistant_mock.complete_chat.assert_called_once_with(
[system_message, {"role": "user", "content": "user_message"}],
override_params={},
override_params={}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls(
[
Expand All @@ -93,7 +93,7 @@ def test_clear():

assistant_mock.complete_chat.assert_called_once_with(
[system_message, {"role": "user", "content": "user_message_1"}],
override_params={},
override_params={}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls(
[
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_rerun():

assistant_mock.complete_chat.assert_called_once_with(
[system_message, {"role": "user", "content": "user_message"}],
override_params={},
override_params={}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls(
[
Expand All @@ -150,7 +150,7 @@ def test_rerun():

assistant_mock.complete_chat.assert_called_once_with(
[system_message, {"role": "user", "content": "user_message"}],
override_params={},
override_params={}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls(
[
Expand All @@ -175,7 +175,7 @@ def test_args():
assistant_message = {"role": "assistant", "content": expected_response}

assistant_mock.complete_chat.assert_called_once_with(
[system_message, user_message], override_params={"arg1": "value1"}
[system_message, user_message], override_params={"arg1": "value1"}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls(
[mock.call(user_message), mock.call(assistant_message)]
Expand All @@ -191,7 +191,7 @@ def test_args():
assert should_continue

assistant_mock.complete_chat.assert_called_once_with(
[system_message, user_message], override_params={"arg1": "value1"}
[system_message, user_message], override_params={"arg1": "value1"}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls([mock.call(assistant_message)])

Expand Down Expand Up @@ -250,7 +250,7 @@ def test_openai_error():
assert should_continue

assistant_mock.complete_chat.assert_called_once_with(
[system_message, user_message], override_params={}
[system_message, user_message], override_params={}, stream=True,
)
listener_mock.on_chat_message.assert_has_calls(
[
Expand Down

0 comments on commit 1d160e8

Please sign in to comment.