Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

test: chat_loop forwards top_k to ka.chat

dex0shubhama7632c11e8f3
diff --git a/tests/cli/test_talk.py b/tests/cli/test_talk.py
new file mode 100644
index 0000000..eb19cc6
--- /dev/null
+++ b/tests/cli/test_talk.py
@@ -0,0 +1,20 @@
+"""Tests for the interactive `he talk` chat loop."""
+
+import hyperextract.cli.cli as climod
+
+
+def test_chat_loop_passes_top_k(monkeypatch):
+ """Interactive chat must forward top_k to ka.chat, not use the default."""
+ recorded = {}
+
+ class _StubKA:
+ def chat(self, query, top_k=3):
+ recorded["top_k"] = top_k
+ return type("_Resp", (), {"content": "ok"})()
+
+ queries = iter(["hello", "exit"])
+ monkeypatch.setattr(climod.console, "input", lambda *a, **k: next(queries))
+
+ climod.chat_loop(_StubKA(), "some/ka", top_k=10)
+
+ assert recorded["top_k"] == 10