refactor: 优化工具脚本接口并修复批处理问题

This commit is contained in:
2026-04-05 21:56:22 +08:00
parent e58dbd7c57
commit 9b22b1651e
8 changed files with 140 additions and 64 deletions
+8 -1
View File
@@ -269,13 +269,20 @@ class InferenceEngine:
result = _NonStreamingResult(len(prompts))
for i, p in enumerate(prompts):
# Create closure to capture current index value using factory function
def make_callback(idx):
def callback(token):
result.append(idx, token)
return callback
self.scheduler.add_task(
prompt=p,
max_tokens=max_tokens,
temperature=temperature,
top_p=top_p,
top_k=top_k,
stream_callback=result.append,
stream_callback=make_callback(i),
)
result.wait()