(data)
| 228 | temp = {"question": item} |
| 229 | data_list.append(temp) |
| 230 | def process_data(data): |
| 231 | messages = [{"role": "system", "content": "你是 Kimi。"}, {"role": "user", "content": data["question"]}] |
| 232 | finish_reason = None |
| 233 | while finish_reason is None or finish_reason == "tool_calls": |
| 234 | choice = chat(messages) |
| 235 | finish_reason = choice.finish_reason |
| 236 | if finish_reason == "tool_calls": |
| 237 | messages.append(choice.message) |
| 238 | for tool_call in choice.message.tool_calls: |
| 239 | tool_result = search_impl(json.loads(tool_call.function.arguments)) |
| 240 | messages.append({ |
| 241 | "role": "tool", |
| 242 | "tool_call_id": tool_call.id, |
| 243 | "name": tool_call.function.name, |
| 244 | "content": json.dumps(tool_result), |
| 245 | }) |
| 246 | data["pred"] = choice.message.content |
| 247 | return data |
| 248 | |
| 249 | with tqdm(total=len(data_list)) as pbar: |
| 250 | with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor: |
nothing calls this directly
no test coverage detected