feat(cli): support conversational AI follow-ups in interactive mode
This commit is contained in:
@@ -116,6 +116,34 @@ def test_stream_yields_chunks() -> None:
|
||||
assert result == ["Root ", "cause ", "found."]
|
||||
|
||||
|
||||
def test_stream_messages_yields_chunks() -> None:
|
||||
config = AIConfig()
|
||||
client = AIClient(config)
|
||||
|
||||
def _make_chunk(text: str | None) -> MagicMock:
|
||||
delta = MagicMock()
|
||||
delta.content = text
|
||||
choice = MagicMock()
|
||||
choice.delta = delta
|
||||
chunk = MagicMock()
|
||||
chunk.choices = [choice]
|
||||
return chunk
|
||||
|
||||
mock_chunks = [_make_chunk("A"), _make_chunk(None), _make_chunk("B")]
|
||||
|
||||
with patch.object(client._client.chat.completions, "create", return_value=iter(mock_chunks)):
|
||||
result = list(
|
||||
client.stream_messages(
|
||||
[
|
||||
{"role": "system", "content": "sys"},
|
||||
{"role": "user", "content": "question"},
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
assert result == ["A", "B"]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# prompt_builder
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user