-
Notifications
You must be signed in to change notification settings - Fork 276
feat: added new flag default-template for models to use tools #1946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -647,9 +647,12 @@ def llama_serve(self, args): | |||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||
| exec_args += ["--jinja"] | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| chat_template_path = self._get_chat_template_path(args.container, args.generate, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| if chat_template_path is not None: | ||||||||||||||||||||||||||||||||||||||||
| exec_args += ["--chat-template-file", chat_template_path] | ||||||||||||||||||||||||||||||||||||||||
| # Add chat template unless using default template | ||||||||||||||||||||||||||||||||||||||||
| use_default_template = getattr(args, 'default_template', False) | ||||||||||||||||||||||||||||||||||||||||
| if not use_default_template: | ||||||||||||||||||||||||||||||||||||||||
| chat_template_path = self._get_chat_template_path(args.container, args.generate, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| if chat_template_path is not None: | ||||||||||||||||||||||||||||||||||||||||
| exec_args += ["--chat-template-file", chat_template_path] | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if should_colorize(): | ||||||||||||||||||||||||||||||||||||||||
| exec_args += ["--log-colors", "on"] | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -739,44 +742,55 @@ def handle_runtime(self, args, exec_args): | |||||||||||||||||||||||||||||||||||||||
| def generate_container_config(self, args, exec_args): | ||||||||||||||||||||||||||||||||||||||||
| # Get the blob paths (src) and mounted paths (dest) | ||||||||||||||||||||||||||||||||||||||||
| model_src_path = self._get_entry_model_path(False, False, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| chat_template_src_path = self._get_chat_template_path(False, False, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| mmproj_src_path = self._get_mmproj_path(False, False, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| model_dest_path = self._get_entry_model_path(True, True, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| chat_template_dest_path = self._get_chat_template_path(True, True, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| mmproj_dest_path = self._get_mmproj_path(True, True, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Get chat template paths unless using default template | ||||||||||||||||||||||||||||||||||||||||
| use_default_template = getattr(args, 'default_template', False) | ||||||||||||||||||||||||||||||||||||||||
| if use_default_template: | ||||||||||||||||||||||||||||||||||||||||
| chat_template_src_path = None | ||||||||||||||||||||||||||||||||||||||||
| chat_template_dest_path = None | ||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||
| chat_template_src_path = self._get_chat_template_path(False, False, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
| chat_template_dest_path = self._get_chat_template_path(True, True, args.dryrun) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Prepare chat template paths tuple or None | ||||||||||||||||||||||||||||||||||||||||
| chat_template_paths = None if chat_template_src_path is None else (chat_template_src_path, chat_template_dest_path) | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+749
to
+759
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic for determining
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| mmproj_paths = None if mmproj_src_path is None else (mmproj_src_path, mmproj_dest_path) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if args.generate.gen_type == "quadlet": | ||||||||||||||||||||||||||||||||||||||||
| self.quadlet( | ||||||||||||||||||||||||||||||||||||||||
| (model_src_path, model_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (chat_template_src_path, chat_template_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (mmproj_src_path, mmproj_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| chat_template_paths, | ||||||||||||||||||||||||||||||||||||||||
| mmproj_paths, | ||||||||||||||||||||||||||||||||||||||||
| args, | ||||||||||||||||||||||||||||||||||||||||
| exec_args, | ||||||||||||||||||||||||||||||||||||||||
| args.generate.output_dir, | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| elif args.generate.gen_type == "kube": | ||||||||||||||||||||||||||||||||||||||||
| self.kube( | ||||||||||||||||||||||||||||||||||||||||
| (model_src_path, model_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (chat_template_src_path, chat_template_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (mmproj_src_path, mmproj_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| chat_template_paths, | ||||||||||||||||||||||||||||||||||||||||
| mmproj_paths, | ||||||||||||||||||||||||||||||||||||||||
| args, | ||||||||||||||||||||||||||||||||||||||||
| exec_args, | ||||||||||||||||||||||||||||||||||||||||
| args.generate.output_dir, | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| elif args.generate.gen_type == "quadlet/kube": | ||||||||||||||||||||||||||||||||||||||||
| self.quadlet_kube( | ||||||||||||||||||||||||||||||||||||||||
| (model_src_path, model_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (chat_template_src_path, chat_template_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (mmproj_src_path, mmproj_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| chat_template_paths, | ||||||||||||||||||||||||||||||||||||||||
| mmproj_paths, | ||||||||||||||||||||||||||||||||||||||||
| args, | ||||||||||||||||||||||||||||||||||||||||
| exec_args, | ||||||||||||||||||||||||||||||||||||||||
| args.generate.output_dir, | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| elif args.generate.gen_type == "compose": | ||||||||||||||||||||||||||||||||||||||||
| self.compose( | ||||||||||||||||||||||||||||||||||||||||
| (model_src_path, model_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (chat_template_src_path, chat_template_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| (mmproj_src_path, mmproj_dest_path), | ||||||||||||||||||||||||||||||||||||||||
| chat_template_paths, | ||||||||||||||||||||||||||||||||||||||||
| mmproj_paths, | ||||||||||||||||||||||||||||||||||||||||
| args, | ||||||||||||||||||||||||||||||||||||||||
| exec_args, | ||||||||||||||||||||||||||||||||||||||||
| args.generate.output_dir, | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Type coercion for 'default_template' from request_args may be needed.
Explicitly convert 'default_template' to a boolean to prevent logic errors from string values like 'false' or '0'.