MCPcopy
hub / github.com/InternLM/lmdeploy / get_lora_adapters

Function get_lora_adapters

lmdeploy/cli/utils.py:42–68  ·  view source on GitHub ↗

Parse lora adapers from cli input. Args: adapters (list[str]): CLI input string of lora adapter path(s). Returns: dict[str, str] | None: Parsed lora adapter path(s).

(adapters: list[str])

Source from the content-addressed store, hash-verified

40
41
42def get_lora_adapters(adapters: list[str]):
43 """Parse lora adapers from cli input.
44
45 Args:
46 adapters (list[str]): CLI input string of lora adapter path(s).
47
48 Returns:
49 dict[str, str] | None: Parsed lora adapter path(s).
50 """
51 if not adapters:
52 return None
53 n = len(adapters)
54 output = {}
55 if n == 1:
56 name = 'default'
57 path = adapters[0].strip()
58 if '=' in path:
59 name, path = path.split('=', 1)
60 output[name] = path
61 else:
62 for pair in adapters:
63 assert '=' in pair, f'Multiple lora paths must in format of ' \
64 f'xxx=yyy. But given: {pair}'
65 name, path = pair.strip().split('=', 1)
66 assert name not in output, f'Multiple lora paths with repeated lora name: {name}'
67 output[name] = path
68 return output
69
70
71def get_chat_template(chat_template: str, model_path: str = None):

Callers 3

build_pipeFunction · 0.85
get_adapter_nameFunction · 0.85
api_serverMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected