(prompt, sys_prompt, temperature, max_new_tokens, device,
model_path, device_map, torch_dtype, state)
| 138 | return state |
| 139 | |
| 140 | def run_single(prompt, sys_prompt, temperature, max_new_tokens, device, |
| 141 | model_path, device_map, torch_dtype, state): |
| 142 | if not prompt or not str(prompt).strip(): |
| 143 | return "", "请先输入提示词。", state |
| 144 | |
| 145 | t0 = time.time() |
| 146 | state = ensure_enhancer(state, model_path, device_map, torch_dtype) |
| 147 | enhancer = state["enhancer"] |
| 148 | try: |
| 149 | out = enhancer.predict( |
| 150 | prompt_cot=prompt, |
| 151 | sys_prompt=sys_prompt, |
| 152 | temperature=temperature, |
| 153 | max_new_tokens=max_new_tokens, |
| 154 | device=device |
| 155 | ) |
| 156 | dt = time.time() - t0 |
| 157 | return out, f"耗时:{dt:.2f}s", state |
| 158 | except Exception as e: |
| 159 | return "", f"推理失败:{e}", state |
| 160 | |
| 161 | def run_batch(batch_text, sys_prompt, temperature, max_new_tokens, device, |
| 162 | model_path, device_map, torch_dtype, state): |
nothing calls this directly
no test coverage detected