MCPcopy Create free account
hub / github.com/Hunyuan-PromptEnhancer/PromptEnhancer / run_single

Function run_single

inference/app.py:140–159  ·  view source on GitHub ↗
(prompt, sys_prompt, temperature, max_new_tokens, device,
               model_path, device_map, torch_dtype, state)

Source from the content-addressed store, hash-verified

138 return state
139
140def 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
161def run_batch(batch_text, sys_prompt, temperature, max_new_tokens, device,
162 model_path, device_map, torch_dtype, state):

Callers

nothing calls this directly

Calls 2

ensure_enhancerFunction · 0.70
predictMethod · 0.45

Tested by

no test coverage detected