MCPcopy Index your code
hub / github.com/InternLM/lmdeploy / chat_template

Method chat_template

lmdeploy/model.py:71–80  ·  view source on GitHub ↗
(self, trust_remote_code: bool = False)

Source from the content-addressed store, hash-verified

69 stop_words: list[str] | None = None
70
71 def chat_template(self, trust_remote_code: bool = False):
72 attrs = {key: value for key, value in dataclasses.asdict(self).items() if value is not None}
73 attrs.pop('model_name', None)
74 if self.model_name in MODELS.module_dict.keys():
75 model = MODELS.get(self.model_name)(**attrs, trust_remote_code=trust_remote_code)
76 else:
77 logger.warning(f'Could not find {self.model_name} in registered models. '
78 f'Register {self.model_name} using the BaseChatTemplate.')
79 model = BaseChatTemplate(**attrs, trust_remote_code=trust_remote_code)
80 return model
81
82 def to_json(self, file_path=None):
83 """Convert the dataclass instance to a JSON formatted string and

Callers 1

get_chat_templateFunction · 0.95

Calls 5

BaseChatTemplateClass · 0.85
itemsMethod · 0.80
popMethod · 0.45
keysMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected