Elffuss BraidHub

kikocis/continue public

move check to an outer layer
Changeset80e64a13e0b23a5820e14d64bd28c517d0b74d6aa5ebf8de415ce80394b0d265
AuthorJacob Kim <jacob@continue.dev> · 2025-07-02 17:53 -07:00
CommitterJacob Kim <jacob@continue.dev> · 2025-07-02 17:53 -07:00
Parents9da59f739c22

Browse the files at this changeset

1 file changed

modified core/nextEdit/templating/NextEditPromptEngine.ts +14 −12
@@ -51,16 +51,7 @@
5151 ): TemplateRenderer {
5252 let template = NEXT_EDIT_MODEL_TEMPLATES[modelName];
5353 if (!template) {
54- // Check if modelName includes any known model name as substring.
55- const matchingModel = Object.keys(NEXT_EDIT_MODEL_TEMPLATES).find((key) =>
56- modelName.includes(key),
57- );
58-
59- if (matchingModel) {
60- template = NEXT_EDIT_MODEL_TEMPLATES[matchingModel as NextEditModelName];
61- } else {
62- throw new Error(`Model ${modelName} is not supported for next edit.`);
63- }
54+ throw new Error(`Model ${modelName} is not supported for next edit.`);
6455 }
6556
6657 const compiledTemplate = Handlebars.compile(template.template);
@@ -74,7 +65,7 @@
7465 helper: HelperVars,
7566 userEdits: string,
7667 ): UserPrompt {
77- const modelName = helper.modelName as NextEditModelName;
68+ let modelName = helper.modelName as NextEditModelName;
7869
7970 if (modelName === "this field is not used") {
8071 return {
@@ -85,7 +76,18 @@
8576
8677 // Validate that the modelName is actually a supported model.
8778 if (!Object.keys(NEXT_EDIT_MODEL_TEMPLATES).includes(modelName)) {
88- throw new Error(`${helper.modelName} is not yet supported for next edit.`);
79+ // Check if modelName includes any known model name as substring.
80+ const matchingModel = Object.keys(NEXT_EDIT_MODEL_TEMPLATES).find((key) =>
81+ modelName.includes(key),
82+ );
83+
84+ if (matchingModel) {
85+ modelName = matchingModel as NextEditModelName;
86+ } else {
87+ throw new Error(
88+ `${helper.modelName} is not yet supported for next edit.`,
89+ );
90+ }
8991 }
9092
9193 const renderer = templateRendererOfModel(modelName);