Switch the Main Model to a new LLM
(self, args)
| 85 | self.original_read_only_fnames = set(original_read_only_fnames or []) |
| 86 | |
| 87 | def cmd_model(self, args): |
| 88 | "Switch the Main Model to a new LLM" |
| 89 | |
| 90 | model_name = args.strip() |
| 91 | if not model_name: |
| 92 | announcements = "\n".join(self.coder.get_announcements()) |
| 93 | self.io.tool_output(announcements) |
| 94 | return |
| 95 | |
| 96 | model = models.Model( |
| 97 | model_name, |
| 98 | editor_model=self.coder.main_model.editor_model.name, |
| 99 | weak_model=self.coder.main_model.weak_model.name, |
| 100 | ) |
| 101 | models.sanity_check_models(self.io, model) |
| 102 | |
| 103 | # Check if the current edit format is the default for the old model |
| 104 | old_model_edit_format = self.coder.main_model.edit_format |
| 105 | current_edit_format = self.coder.edit_format |
| 106 | |
| 107 | new_edit_format = current_edit_format |
| 108 | if current_edit_format == old_model_edit_format: |
| 109 | # If the user was using the old model's default, switch to the new model's default |
| 110 | new_edit_format = model.edit_format |
| 111 | |
| 112 | raise SwitchCoder(main_model=model, edit_format=new_edit_format) |
| 113 | |
| 114 | def cmd_editor_model(self, args): |
| 115 | "Switch the Editor Model to a new LLM" |