diff --git a/comps/cores/mega/orchestrator.py b/comps/cores/mega/orchestrator.py index 8a75f9cff..803965f6e 100644 --- a/comps/cores/mega/orchestrator.py +++ b/comps/cores/mega/orchestrator.py @@ -237,8 +237,8 @@ def generate(): ) token_start = time.time() else: - yield chunk token_start = self.metrics.token_update(token_start, is_first) + yield chunk is_first = False self.metrics.request_update(req_start) self.metrics.pending_update(False) @@ -306,7 +306,7 @@ def token_generator(self, sentence: str, token_start: float, is_first: bool, is_ suffix = "\n\n" tokens = re.findall(r"\s?\S+\s?", sentence, re.UNICODE) for token in tokens: - yield prefix + repr(token.replace("\\n", "\n").encode("utf-8")) + suffix token_start = self.metrics.token_update(token_start, is_first) + yield prefix + repr(token.replace("\\n", "\n").encode("utf-8")) + suffix if is_last: yield "data: [DONE]\n\n"