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

Function main

lmdeploy/cli/chat.py:72–107  ·  view source on GitHub ↗
(model_path, backend, trust_remote_code=False, **kwargs)

Source from the content-addressed store, hash-verified

70
71
72def main(model_path, backend, trust_remote_code=False, **kwargs):
73 if backend != 'pytorch':
74 # set auto backend mode
75 backend = autoget_backend(model_path, trust_remote_code=trust_remote_code)
76 quit = False
77 with build_pipe(model_path, backend, trust_remote_code=trust_remote_code, **kwargs) as pipe:
78 gen_config = build_gen_config(**kwargs)
79 adapter_name = get_adapter_name(**kwargs)
80 while not quit:
81 with closing(pipe.session()) as sess:
82 while True:
83 try:
84 prompt = input_prompt()
85 except KeyboardInterrupt:
86 quit = True
87 break
88 if prompt == 'end':
89 sess.close()
90 break
91 if prompt == 'exit':
92 quit = True
93 break
94 if prompt.strip() == '':
95 continue
96 resps = pipe.chat(prompt,
97 session=sess,
98 gen_config=gen_config,
99 adapter_name=adapter_name,
100 stream_response=True)
101 try:
102 for resp in resps:
103 print(resp.text, end='', flush=True)
104 except KeyboardInterrupt:
105 sess.abort()
106 else:
107 print('exiting...')
108
109
110if __name__ == '__main__':

Callers 1

chatMethod · 0.70

Calls 9

autoget_backendFunction · 0.90
build_pipeFunction · 0.85
build_gen_configFunction · 0.85
get_adapter_nameFunction · 0.85
input_promptFunction · 0.85
sessionMethod · 0.80
abortMethod · 0.80
closeMethod · 0.45
chatMethod · 0.45

Tested by

no test coverage detected