Skip to content

Commit c07f7f6

Browse files
committed
#75 related attachment of unit-test. Updated / simplified callback implementation.
1 parent ae5b51e commit c07f7f6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test/test_api_streaming.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,22 @@ def test_iter(self):
2121

2222
streamed_logger = StreamedLogger(__name__)
2323

24-
def callback(chunk, info, reg):
25-
26-
if info["param"] not in reg:
27-
current_field = info["param"]
28-
streamed_logger.info(f"\n{current_field} (batch_ind={info['ind']}):\n")
29-
reg.add(info["param"])
30-
24+
def callback(chunk, info):
25+
if chunk is None and info["action"] == "start":
26+
streamed_logger.info(f"\n{info['param']} (batch_ind={info['ind']}):\n")
27+
return
28+
if chunk is None and info["action"] == "end":
29+
streamed_logger.info("\n\n")
30+
return
3131
streamed_logger.info(chunk)
3232

33-
reg = set()
3433
input_dicts_it = iter_test_jsonl_samples()
3534
data_it = iter_content(input_dicts_it=input_dicts_it,
3635
llm=self.llm,
3736
return_batch=False,
38-
callback_stream_func=lambda chunk, info: callback(chunk, info, reg),
37+
callback_stream_func=callback,
38+
handle_missed_value_func=lambda *_: None,
3939
schema="schema/thor_cot_schema.json")
4040

4141
for _ in tqdm(data_it):
42-
reg.clear()
4342
streamed_logger.info("\n|NEXT ENTRY|\n")

0 commit comments

Comments
 (0)