MCPcopy
hub / github.com/QwenLM/Qwen3 / main

Function main

examples/demo/cli_demo.py:169–293  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167
168
169def main():
170 parser = argparse.ArgumentParser(
171 description="Qwen2.5-Instruct command-line interactive chat demo."
172 )
173 parser.add_argument(
174 "-c",
175 "--checkpoint-path",
176 type=str,
177 default=DEFAULT_CKPT_PATH,
178 help="Checkpoint name or path, default to %(default)r",
179 )
180 parser.add_argument("-s", "--seed", type=int, default=1234, help="Random seed")
181 parser.add_argument(
182 "--cpu-only", action="store_true", help="Run demo with CPU only"
183 )
184 args = parser.parse_args()
185
186 history, response = [], ""
187
188 model, tokenizer = _load_model_tokenizer(args)
189 orig_gen_config = deepcopy(model.generation_config)
190
191 _setup_readline()
192
193 _clear_screen()
194 print(_WELCOME_MSG)
195
196 seed = args.seed
197
198 while True:
199 query = _get_input()
200
201 # Process commands.
202 if query.startswith(":"):
203 command_words = query[1:].strip().split()
204 if not command_words:
205 command = ""
206 else:
207 command = command_words[0]
208
209 if command in ["exit", "quit", "q"]:
210 break
211 elif command in ["clear", "cl"]:
212 _clear_screen()
213 print(_WELCOME_MSG)
214 _gc()
215 continue
216 elif command in ["clear-history", "clh"]:
217 print(f"[INFO] All {len(history)} history cleared")
218 history.clear()
219 _gc()
220 continue
221 elif command in ["help", "h"]:
222 print(_HELP_MSG)
223 continue
224 elif command in ["history", "his"]:
225 _print_history(history)
226 continue

Callers 1

cli_demo.pyFile · 0.70

Calls 7

_setup_readlineFunction · 0.85
_clear_screenFunction · 0.85
_get_inputFunction · 0.85
_print_historyFunction · 0.85
_load_model_tokenizerFunction · 0.70
_gcFunction · 0.70
_chat_streamFunction · 0.70

Tested by

no test coverage detected