MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / do_apply_chat_template

Method do_apply_chat_template

tensorrt_llm/evaluate/interface.py:56–71  ·  view source on GitHub ↗
(self, llm: Any,
                               prompt: Union[str, List[dict]])

Source from the content-addressed store, hash-verified

54 raise NotImplementedError()
55
56 def do_apply_chat_template(self, llm: Any,
57 prompt: Union[str, List[dict]]) -> str:
58 if isinstance(prompt, str):
59 messages = [{"role": "user", "content": prompt}]
60 else:
61 messages = prompt
62 if self.system_prompt is not None:
63 messages = [{
64 "role": "system",
65 "content": self.system_prompt
66 }] + messages
67 return llm.tokenizer.apply_chat_template(messages,
68 tokenize=False,
69 add_generation_prompt=True,
70 **(self.chat_template_kwargs
71 or {}))
72
73 def _get_sampline_params(self, sampling_params: Optional[SamplingParams],
74 sampling_args: Optional[dict]) -> SamplingParams:

Callers 1

evaluateMethod · 0.95

Calls 1

apply_chat_templateMethod · 0.45

Tested by

no test coverage detected